unsqueeze(input, axes, name=None)
Insert single-dimensional entries to the shape of a Tensor. Takes one required argument axes, a list of dimensions that will be inserted. Dimension indices in axes are as seen in the output tensor.
Given a tensor such that tensor with shape [3, 4, 5], then Unsqueezed tensor with axes=[0, 4] has shape [1, 3, 4, 5, 1].
input (Variable) – The input Tensor to be unsqueezed. It is a N-D Tensor of data types float32, float64, int32.
axes (int|list|tuple|Variable) – Indicates the dimensions to be inserted. The data type is
axesis a list or tuple, the elements of it should be integers or Tensors with shape . If
axesis an Variable, it should be an 1-D Tensor .
name (str|None) – Name for this layer.
Output unsqueezed Tensor, with data type being float32, float64, int32, int64.
- Return type
import paddle.fluid as fluid x = fluid.layers.data(name='x', shape=[5, 10]) y = fluid.layers.unsqueeze(input=x, axes=)