- class paddle.nn. Unflatten ( axis, shape, name=None )
This interface is used to construct a callable object of the
Unflattenclass. For more details, refer to code examples. It a certain dimension of the input x Tensor into a desired shape.
axis (int) –
axisto be unflattened, specified as an index into x.shape.
shape (list|tuple|Tensor) – Unflatten
shapeon the specified
axis. At most one dimension of the target
shapecan be -1. If the input
shapedoes not contain -1 , the product of all elements in
shapeshould be equal to
x.shape[axis]. The data type is int . If
shapeis a list or tuple, the elements of it should be integers or Tensors with shape . If
shapeis an Tensor, it should be an 1-D Tensor.
name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.
import paddle x = paddle.randn(shape=[4, 6, 8]) shape = [2, 3] axis = 1 unflatten = paddle.nn.Unflatten(axis, shape) res = unflatten(x) print(res.shape) # [4, 2, 3, 8]
Defines the computation performed at every call. Should be overridden by all subclasses.
*inputs (tuple) – unpacked tuple arguments
**kwargs (dict) – unpacked dict arguments
Extra representation of this layer, you can have custom implementation of your own layer.