mindspore/docs/api/api_python/numpy/mindspore.numpy.reshape.rst

17 lines
896 B
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.numpy.reshape
=================================
.. py:function:: mindspore.numpy.reshape(x, new_shape)
在不改变数据的情况下重塑一个Tensor。
参数:
- **x** (Tensor) - 需要重塑的Tensor。
- **new_shape** (Union[int, list(int), tuple(int)]) - Tensor的新shape。必须与原始shape兼容。如果 ``new_shape`` 是一个只有一个元素的tuple则结果将是一个具有该长度的一维Tensor。 ``new_shape`` 中的一个维度可以是-1此时该维度的值将根据Tensor的总长度和其他维度的大小推断得出。
返回:
重塑后的Tensor其数据类型与原始Tensor ``x`` 相同。
异常:
- **TypeError** - 如果 ``new_shape`` 既不是整数、list或tuple或者 ``x`` 不是Tensor。
- **ValueError** - 如果 ``new_shape````x`` 的原始shape不兼容。