Tensor.trace
- Tensor.trace(axis1=0, axis2=1)[source]
Returns the sum along diagonals of the tensor.
- Parameters
axis1 (int) – Axes to be used as the first and second axis of the 2-D sub-tensors from which the diagonals should be taken. Defaults are the first two axes of the tensor.
axis2 (int) – Axes to be used as the first and second axis of the 2-D sub-tensors from which the diagonals should be taken. Defaults are the first two axes of the tensor.
- Returns
If the tensor is 2-D, the sum along along the diagonal is returned. If the tensor is N-D, with N > 2, then a (N-2)-D tensor of sums along diagonals is returned.
- Return type
Self | Number