Remove single-dimensional entries from the shape of an array.
LAX-backend implementation of
squeeze(). Original docstring below.
squeezed – 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.
- Return type
ValueError – If axis is not None, and an axis being squeezed is not of length 1
>>> x = np.array([[, , ]]) >>> x.shape (1, 3, 1) >>> np.squeeze(x).shape (3,) >>> np.squeeze(x, axis=0).shape (3, 1) >>> np.squeeze(x, axis=1).shape Traceback (most recent call last): ... ValueError: cannot select an axis to squeeze out which has size not equal to one >>> np.squeeze(x, axis=2).shape (1, 3)