MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _summarize_eager

Function _summarize_eager

tensorflow/python/ops/control_flow_ops.py:78–104  ·  view source on GitHub ↗

Returns a summarized string representation of eager `tensor`. Args: tensor: EagerTensor to summarize summarize: Include these many first elements of `array`

(tensor, summarize=None)

Source from the content-addressed store, hash-verified

76
77
78def _summarize_eager(tensor, summarize=None):
79 """Returns a summarized string representation of eager `tensor`.
80
81 Args:
82 tensor: EagerTensor to summarize
83 summarize: Include these many first elements of `array`
84 """
85 # Emulate the behavior of Tensor::SummarizeValue()
86 if summarize is None:
87 summarize = 3
88 elif summarize < 0:
89 summarize = array_ops.size(tensor)
90
91 # reshape((-1,)) is the fastest way to get a flat array view
92 if tensor._rank(): # pylint: disable=protected-access
93 flat = tensor.numpy().reshape((-1,))
94 lst = [str(x) for x in flat[:summarize]]
95 if len(lst) < flat.size:
96 lst.append("...")
97 else:
98 # tensor.numpy() returns a scalar for zero dimensional arrays
99 if gen_math_ops.not_equal(summarize, 0):
100 lst = [str(tensor.numpy())]
101 else:
102 lst = []
103
104 return ", ".join(lst)
105
106
107# pylint: disable=protected-access

Callers 1

AssertFunction · 0.85

Calls 7

reshapeMethod · 0.80
not_equalMethod · 0.80
sizeMethod · 0.45
_rankMethod · 0.45
numpyMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected