ZeroPad3D

class paddle.nn. ZeroPad3D ( padding, data_format='NCDHW', name=None ) [source]

This interface is used to construct a callable object of the ZeroPad3D class. Pads the input tensor boundaries with zero.

Parameters
  • padding (Tensor | List[int] | int) – The padding size with data type int. If is int, use the same padding in all dimensions. Else [len(padding)/2] dimensions of input will be padded. The pad has the form (pad_left, pad_right, pad_top, pad_bottom, pad_front, pad_back).

  • data_format (str) – An string from: “NCDHW”, “NDHWC”. Specify the data format of the input data. Default is “NCDHW”

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Shape:
  • x(Tensor): The input tensor of zeropad3d operator, which is a 5-D tensor. The data type can be float32, float64.

  • output(Tensor): The output tensor of zeropad3d operator, which is a 5-D tensor. The data type is same as input x.

Examples

>>> import paddle
>>> import paddle.nn as nn

>>> input_shape = (1, 1, 1, 2, 3)
>>> pad = [1, 0, 1, 2, 0, 0]
>>> data = paddle.arange(paddle.prod(paddle.to_tensor(input_shape)), dtype="float32").reshape(input_shape) + 1
>>> my_pad = nn.ZeroPad3D(padding=pad)
>>> result = my_pad(data)
>>> print(result)
Tensor(shape=[1, 1, 1, 5, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[[[0., 0., 0., 0.],
    [0., 1., 2., 3.],
    [0., 4., 5., 6.],
    [0., 0., 0., 0.],
    [0., 0., 0., 0.]]]]])
forward ( x )

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( )

extra_repr

Extra representation of this layer, you can have custom implementation of your own layer.