Tensor.sum
- Tensor.sum(axis=None, out=None)[source]
Sum of tensor elements over a given axis or tuple of axes.
- Parameters
axis (int | Tuple[int] | None) – Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input tensor. If axis is negative it counts from the last to the first axis. If axis is a tuple of ints, a sum is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.
out (np.ndarray | None) – Alternative output array in which to place the result. It must have the same shape as the expected output, but the type of the output values will be cast if necessary. Default: None.
- Returns
A tensor with the specified axis or set of axes removed.
- Return type
Self | Number