mindspore.mint.nn.ReplicationPad1d

View Source On AtomGit
class mindspore.mint.nn.ReplicationPad1d(padding)[source]

Pad the last dimension of input tensor using the replication of the input boundary.

For more information, please refer to mindspore.mint.nn.functional.pad().

Warning

This is an experimental API that is subject to change or deletion.

Parameters

padding (Union[int, tuple, list]) –

Padding size.

  • If an int, pads all boundaries with the same amount.

  • If a tuple or list, it should be in the order \((pad_{left}, pad_{right})\).

Inputs:
  • input (Tensor) - The input tensor, with shape \((C, W_{in})\) or \((N, C, W_{in})\).

Outputs:

Tensor, the tensor after padding.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> pad1d = mindspore.mint.nn.ReplicationPad1d(2)
>>> input = mindspore.tensor(mindspore.mint.arange(0, 8).reshape(1, 2, 4), mindspore.float32)
>>> print(input)
[[[0. 1. 2. 3.]
  [4. 5. 6. 7.]]]
>>> out = pad1d(input)
>>> print(out)
[[[0. 0. 0. 1. 2. 3. 3. 3.]
  [4. 4. 4. 5. 6. 7. 7. 7.]]]
>>> pad1d = mindspore.mint.nn.ReplicationPad1d((3, 1))
>>> out = pad1d(input)
>>> print(out)
[[[0. 0. 0. 0. 1. 2. 3. 3.]
  [4. 4. 4. 4. 5. 6. 7. 7.]]]