megengine.functional.reshape¶
-
reshape
(inp, target_shape)[源代码]¶ 将一个张量重塑为给定的目标形状;逻辑元素的总数必须保持不变
- 参数
- 返回类型
megengine.tensor.Tensor
例如:
import numpy as np from megengine import tensor import megengine.functional as F x = tensor(np.arange(12, dtype=np.int32)) out = F.reshape(x, (3, 4)) print(out.numpy())
输出:
[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]]
- 返回类型
Tensor
- 参数
inp (megengine.tensor.Tensor) –
target_shape (Iterable[int]) –