squeeze¶
-
paddle.fluid.layers.
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 = [0] 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]
- Parameters
input (Variable) – The input Tensor. Support data type: float16, float32, float64, 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.
- Returns
Output squeezed Tensor. Data type is same as input Tensor.
- Return type
Variable
Examples
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=[2]) # y.shape=[None, 5, 10]