megengine.functional.squeeze

squeeze(inp, axis=None)[source]

Removes dimension of shape 1.

Parameters
Return type

Tensor

Returns

output tensor.

Examples

>>> import numpy as np
>>> x = Tensor(np.array([1, 2], dtype=np.int32).reshape(1, 1, 2, 1))
>>> out = F.squeeze(x, 3)
>>> out.numpy().shape
(1, 1, 2)