mindspore.numpy.expand_dims
- mindspore.numpy.expand_dims(a, axis)[源代码]
Expands the shape of a tensor.
Inserts a new axis that will appear at the axis position in the expanded tensor shape.
- 参数
- 返回
Tensor, with the number of dimensions increased at specified axis.
- 异常
TypeError – If input arguments have types not specified above.
ValueError – If axis exceeds a.ndim.
- Supported Platforms:
Ascend
GPU
CPU
样例
>>> import mindspore.numpy as np >>> x = np.ones((2,2)) >>> x = np.expand_dims(x,0) >>> print(x.shape) (1, 2, 2)