pad

dragon.vm.torch.nn.functional.pad(
  input,
  pad,
  mode='constant',
  value=0
)[source]

Pad the input according to the given sizes.

The padded dimension is computed as:

\[\text{Dim}_{out} = \text{Dim}_{in} + pad_l + pad_r \]

The pad should be a sequence of \((N, 2)\) values, where \(N\) is the last n-dimensions to pad.

Parameters:
  • input (dragon.vm.torch.Tensor) The input tensor.
  • pad (Sequence[int]) The n-d padding sizes.
  • mode ({'constant', 'reflect', 'replicate', 'circular'}, optional) The padding mode.
  • value (number, optional, default=0) The value used in constant mode.
Returns:

dragon.vm.torch.Tensor The output tensor.