mindspore.mint.nn.ReflectionPad2d
- class mindspore.mint.nn.ReflectionPad2d(padding)[source]
Pad the last 2-D dimensions 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 it is an int, pads all boundaries with the same amount.
If it is a tuple or list, it should be in the order \((\text{padding_left}, \text{padding_right}, \text{padding_top}, \text{padding_bottom})\).
- Inputs:
input (Tensor) - The input tensor with shape \((C, H_{in}, W_{in})\) or \((N, C, H_{in}, W_{in})\).
- Outputs:
Tensor, the tensor after padding, with shape \((C, H_{out}, W_{out})\) or \((N, C, H_{out}, W_{out})\), where
\(H_{out} = H_{in} + \text{padding_top} + \text{padding_bottom}\)
\(W_{out} = W_{in} + \text{padding_left} + \text{padding_right}\)
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> x = mindspore.tensor([[[0, 1, 2], [3, 4, 5], [6, 7, 8]]], mindspore.float32) >>> padding = (1, 1, 2, 0) >>> pad2d = mindspore.mint.nn.ReflectionPad2d(padding) >>> out = pad2d(x) >>> print(out) [[[7. 6. 7. 8. 7.] [4. 3. 4. 5. 4.] [1. 0. 1. 2. 1.] [4. 3. 4. 5. 4.] [7. 6. 7. 8. 7.]]]