mindspore.Tensor.reshape_as
- Tensor.reshape_as(other)[源代码]
不改变数据的情况下,将Tensor的shape改为 other 的shape。
- 参数:
other (Tensor) - 计算结果的shape与 other 的shape一致。
- 返回:
Tensor,与 other 的shape一致。
- 支持平台:
Ascend
GPU
CPU
样例:
>>> import mindspore as ms >>> from mindspore import Tensor >>> import numpy as np >>> x = Tensor([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]], dtype=ms.float32) >>> y = Tensor(np.arange(6).reshape(3,2)) >>> output = x.reshape_as(y) >>> print(output) [[-0.1 0.3] [ 3.6 0.4] [ 0.5 -3.2]]