mindspore.numpy.expand_dims
- mindspore.numpy.expand_dims(a, axis)[source]
Expands the shape of a tensor.
Inserts a new axis that will appear at the axis position in the expanded tensor shape.
- Parameters
- Returns
Tensor, with the number of dimensions increased at specified axis.
- Raises
TypeError – If input arguments have types not specified above.
ValueError – If axis exceeds a.ndim.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> x = np.ones((2,2)) >>> x = np.expand_dims(x,0) >>> print(x.shape) (1, 2, 2)