mindspore.ops.SquareSumAll
- class mindspore.ops.SquareSumAll[source]
Returns the square sum of a tensor element-wise
\[\begin{split}\left\{\begin{matrix}out_{x} = {\textstyle \sum_{0}^{N}} (x_{i})^2 \\out_{y} = {\textstyle \sum_{0}^{N}} (y_{i})^2 \end{matrix}\right.\end{split}\]- Inputs:
x (Tensor) - The input tensor. The data type must be float16 or float32. \((N,*)\) where \(*\) means, any number of additional dimensions.
y (Tensor) - The input tensor has the same type and shape as the x.
Note
SquareSumAll only supports float16 and float32 data type.
- Outputs:
output_y1 (Tensor) - The same type as the x.
output_y2 (Tensor) - The same type as the x.
- Raises
TypeError – If neither x nor y is a Tensor.
ValueError – If x and y are not the same shape.
- Supported Platforms:
Ascend
GPU
Examples
>>> x = Tensor(np.array([0, 0, 2, 0]), mindspore.float32) >>> y = Tensor(np.array([0, 0, 2, 4]), mindspore.float32) >>> square_sum_all = ops.SquareSumAll() >>> output = square_sum_all(x, y) >>> print(output) (Tensor(shape=[], dtype=Float32, value= 4), Tensor(shape=[], dtype=Float32, value= 20))