mindspore.Tensor.square
- Tensor.square()[source]
Returns square of a tensor element-wise.
\[out_{i} = (x_{i})^2\]- Returns
Tensor, has the same shape and dtype as the x.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32) >>> output = x.square() >>> print(output) [1. 4. 9.]