- paddle.fluid.layers.nn. squeeze ( input, axes, name=None ) [source]
This OP will squeeze single-dimensional entries of input tensor’s shape. If axes is provided, will remove the dims by axes, the dims selected by axes should be one. If not provide axes, all dims equal to one will be deleted.
Case1: Input: X.shape = (1, 3, 1, 5) axes =  Output: Out.shape = (3, 1, 5) Case2: Input: X.shape = (1, 3, 1, 5) axes =  Output: Out.shape = (3, 5) Case3: Input: X.shape = [1,3,1,5] axes = [-2] Output: Out.shape = [1,3,5]
input (Variable) – The input Tensor. Supported data type: float32, float64, bool, int8, int32, int64. axes (list): One integer or List of integers, indicating the dimensions to be squeezed. Axes range is \([-rank(input), rank(input))\). If axes is negative, \(axes=axes+rank(input)\).
name (str, optional) – Please refer to Name, Default None.
Output squeezed Tensor. Data type is same as input Tensor.
- Return type
import paddle.fluid as fluid import paddle.fluid.layers as layers # set batch size=None x = fluid.data(name='x', shape=[None, 5, 1, 10]) y = layers.squeeze(input=x, axes=) # y.shape=[None, 5, 10]