mindspore.mint.nn.ReflectionPad1d
- class mindspore.mint.nn.ReflectionPad1d(padding)[source]
Pad the last dimension of input tensor using the reflection 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]) –
Specifies padding size.
If is int, the same padding is applied to all boundaries.
If a tuple or list, the order is \((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, with shape \((C, W_{out})\) or \((N, C, W_{out})\), where \(W_{out} = W_{in} + ext{padding}_{left} + ext{padding}_{right}\).
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> x = mindspore.tensor([[[0, 1, 2, 3], [4, 5, 6, 7]]], mindspore.float32) >>> padding = (3, 1) >>> pad1d = mindspore.mint.nn.ReflectionPad1d(padding) >>> out = pad1d(x) >>> print(out) [[[3. 2. 1. 0. 1. 2. 3. 2.] [7. 6. 5. 4. 5. 6. 7. 6.]]]