unsqueeze¶
- paddle.fluid.layers.nn. unsqueeze ( input, axes, name=None ) [source]
-
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.
For example:
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].
- Parameters
-
input (Variable) – The input Tensor to be unsqueezed. Supported data type: float32, float64, bool, int8, int32, int64.
axes (int|list|tuple|Variable) – Indicates the dimensions to be inserted. The data type is
int32
. Ifaxes
is a list or tuple, the elements of it should be integers or Tensors with shape [1]. Ifaxes
is an Variable, it should be an 1-D Tensor .name (str|None) – Name for this layer.
- Returns
-
Unsqueezed Tensor, with the same data type as input.
- Return type
-
Variable
Examples
import paddle.fluid as fluid x = fluid.layers.data(name='x', shape=[5, 10]) y = fluid.layers.unsqueeze(input=x, axes=[1])