mindspore.mint.nn.ReplicationPad3d
- class mindspore.mint.nn.ReplicationPad3d(padding)[源代码]
使用输入边界值,对输入 input 的最后三维进行填充。
更多参考详见
mindspore.mint.nn.functional.pad()。警告
这是一个实验性API,后续可能修改或删除。
- 参数:
padding (Union[int, tuple, list]) - 填充的大小。
如果输入为int,则对所有边界进行相同大小的填充。
如果为tuple或list,则顺序为 \((\text{padding_left}, \text{padding_right}, \text{padding_top}, \text{padding_bottom}, \text{padding_front}, \text{padding_back})\)。
- 输入:
input (Tensor) - 输入tensor,shape为 \((C, D_{in}, H_{in}, W_{in})\) 或 \((N, C, D_{in}, H_{in}, W_{in})\)。
- 输出:
Tensor,shape为 \((C, D_{out}, H_{out}, W_{out})\) 或 \((N, C, D_{out}, H_{out}, W_{out})\)。其中:
\(D_{out} = D_{in} + \text{padding_front} + \text{padding_back}\)
\(H_{out} = H_{in} + \text{padding_top} + \text{padding_bottom}\)
\(W_{out} = W_{in} + \text{padding_left} + \text{padding_right}\)
- 支持平台:
Ascend
样例:
>>> import mindspore >>> pad3d = mindspore.mint.nn.ReplicationPad3d(1) >>> input = mindspore.tensor(mindspore.mint.arange(0, 9).reshape(1, 1, 1, 3, 3), mindspore.float32) >>> out = pad3d(input) >>> print(out) [[[[[0. 0. 1. 2. 2.] [0. 0. 1. 2. 2.] [3. 3. 4. 5. 5.] [6. 6. 7. 8. 8.] [6. 6. 7. 8. 8.]] [[0. 0. 1. 2. 2.] [0. 0. 1. 2. 2.] [3. 3. 4. 5. 5.] [6. 6. 7. 8. 8.] [6. 6. 7. 8. 8.]] [[0. 0. 1. 2. 2.] [0. 0. 1. 2. 2.] [3. 3. 4. 5. 5.] [6. 6. 7. 8. 8.] [6. 6. 7. 8. 8.]]]]]