mindspore.numpy.squeeze

mindspore.numpy.squeeze(a, axis=None)[source]

Removes single-dimensional entries from the shape of an tensor.

Parameters
Returns

Tensor, with all or a subset of the dimensions of length \(1\) removed.

Raises
  • TypeError – If input arguments have types not specified above.

  • ValueError – If specified axis has shape entry \(> 1\).

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> x = np.ones((1,2,2,1))
>>> x = np.squeeze(x)
>>> print(x.shape)
(2, 2)