tf.trace(x, name=None)
Compute the trace of a tensor x
.
trace(x)
returns the sum of along the diagonal.
For example:
# 'x' is [[1, 1], # [1, 1]] tf.trace(x) ==> 2 # 'x' is [[1,2,3], # [4,5,6], # [7,8,9]] tf.trace(x) ==> 15
Args:
-
x
: 2-D tensor. -
name
: A name for the operation (optional).
Returns:
The trace of input tensor.
Please login to continue.