You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.ops.Reshape.rst 1.2 kB

1234567891011121314151617181920212223242526272829303132333435
  1. mindspore.ops.Reshape
  2. ======================
  3. .. py:class:: mindspore.ops.Reshape(*args, **kwargs)
  4. 基于给定的shape,使用相同的值对输入Tensor进行reshape操作。
  5. `input_shape` 最多只能有一个-1,在这种情况下,它可以从剩余的维度和输入的元素个数中推断出来。
  6. **输入:**
  7. - **input_x** (Tensor) - Tensor的shape为 :math:`(x_1, x_2, ..., x_R)` 。
  8. - **input_shape** (tuple[int]) - 输入tuple由多个整数构成,如 :math:`(y_1, y_2, ..., y_S)` 。只支持常量值。
  9. **输出:**
  10. Tensor,其shape为 :math:`(y_1, y_2, ..., y_S)` 。
  11. **异常:**
  12. - **ValueError** - 给定的 `input_shape`,如果它有几个-1,或者其元素的乘积小于或等于0,或者无法被输入Tensor的shape的乘积相除,或者与输入的数组大小不匹配。
  13. **支持平台:**
  14. ``Ascend`` ``GPU`` ``CPU``
  15. **样例:**
  16. >>> input_x = Tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]), mindspore.float32)
  17. >>> reshape = ops.Reshape()
  18. >>> output = reshape(input_x, (3, 2))
  19. >>> print(output)
  20. [[-0.1 0.3]
  21. [ 3.6 0.4]
  22. [ 0.5 -3.2]]