Remove single-dimensional entries from the shape of an array.
tensor (tensor_like) – A tensor-like object.
The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into a. Note that if all axes are squeezed, the result is a 0d array and not a scalar.
>>> x = torch.ones((2, 1, 3, 4, 1)) >>> y = squeeze(x) >>> y.shape (2, 3, 4)