mindspore.mint.nn.ReplicationPad2d
- class mindspore.mint.nn.ReplicationPad2d(padding)[source]
Pad the last 2-D dimensions 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]) –
Specifies 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}, pad_{up}, pad_{down})\).
- Inputs:
input (Tensor) - Input tensor, with shape \((C, H_{in}, W_{in})\) or \((N, C, H_{in}, W_{in})\).
- Outputs:
Tensor, with shape \((C, H_{out}, W_{out})\) or \((N, C, H_{out}, W_{out})\). Where:
\(H_{out} = H_{in} + pad_{up} + pad_{down}\)
\(W_{out} = W_{in} + pad_{left} + pad_{right}\) .
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> pad2d = mindspore.mint.nn.ReplicationPad2d(2) >>> input = mindspore.tensor(mindspore.mint.arange(0, 9).reshape(1, 1, 3, 3), mindspore.float32) >>> print(input) [[[[0. 1. 2.] [3. 4. 5.] [6. 7. 8.]]]] >>> out = pad2d(input) >>> print(out) [[[[0. 0. 0. 1. 2. 2. 2.] [0. 0. 0. 1. 2. 2. 2.] [0. 0. 0. 1. 2. 2. 2.] [3. 3. 3. 4. 5. 5. 5.] [6. 6. 6. 7. 8. 8. 8.] [6. 6. 6. 7. 8. 8. 8.] [6. 6. 6. 7. 8. 8. 8.]]]] >>> pad2d = mindspore.mint.nn.ReplicationPad2d((1, 1, 2, 0)) >>> out = pad2d(input) >>> print(out) [[[[0. 0. 1. 2. 2.] [0. 0. 1. 2. 2.] [0. 0. 1. 2. 2.] [3. 3. 4. 5. 5.] [6. 6. 7. 8. 8.]]]]