Reflection Pad 3D
- 类torch.nn.ReflectionPad3d(padding)[源代码]
-
用输入边界镜像来填充输入张量。
对于 N 维填充,可以使用
torch.nn.functional.pad()
函数。- 参数
-
padding (int, tuple) – 填充的大小。如果为 int,则在所有边界使用相同的填充值。如果是 6-元组,则分别使用 ($\text{padding\_left}$, $\text{padding\_right}$, $\text{padding\_top}$, $\text{padding\_bottom}$, $\text{padding\_front}$, $\text{padding\_back}$) 来指定各个方向的填充值。
- 形状:
-
-
输入: $(N, C, D_{in}, H_{in}, W_{in})$ 或 $(C, D_{in}, H_{in}, W_{in})$.
-
输出为:$(N, C, D_{out}, H_{out}, W_{out})$ 或 $(C, D_{out}, H_{out}, W_{out})$,其中
$D_{\text{out}} = D_{\text{in}} + \text{padding\_front} + \text{padding\_back}$
$H_{\text{out}} = H_{\text{in}} + \text{padding\_top} + \text{padding\_bottom}$
$W_{\text{out}} = W_{\text{in}} + \text{padding\_left} + \text{padding\_right}$
-
示例:
>>> m = nn.ReflectionPad3d(1) >>> input = torch.arange(8, dtype=torch.float).reshape(1, 1, 2, 2, 2) >>> m(input) tensor([[[[[7., 6., 7., 6.], [5., 4., 5., 4.], [7., 6., 7., 6.], [5., 4., 5., 4.]], [[3., 2., 3., 2.], [1., 0., 1., 0.], [3., 2., 3., 2.], [1., 0., 1., 0.]], [[7., 6., 7., 6.], [5., 4., 5., 4.], [7., 6., 7., 6.], [5., 4., 5., 4.]], [[3., 2., 3., 2.], [1., 0., 1., 0.], [3., 2., 3., 2.], [1., 0., 1., 0.]]]]])