mindspore.ops.Reshape

class mindspore.ops.Reshape[源代码]

基于给定的shape,对输入Tensor进行重新排列。

更多参考详见 mindspore.ops.reshape()

输入:
  • input_x (Tensor) - Tensor的shape为 (x1,x2,...,xR)

  • input_shape (tuple[int]) - 给定的shape,由多个整数构成,如 (y1,y2,...,yS)

输出:

Tensor,其shape为 (y1,y2,...,yS)

支持平台:

Ascend GPU CPU

样例:

>>> input_x = Tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]), mindspore.float32)
>>> reshape = ops.Reshape()
>>> output = reshape(input_x, (3, 2))
>>> print(output)
[[-0.1  0.3]
 [ 3.6  0.4]
 [ 0.5 -3.2]]