Shortcuts

ReflectionPad3d

class torch.nn.ReflectionPad3d(padding)[源代码]

使用输入边界的反射来填充输入张量。

对于N维填充,使用torch.nn.functional.pad()

Parameters

填充 (int, tuple) – 填充的大小。如果是int,则在所有边界使用相同的填充。如果是6-tuple,则使用 (padding_left\text{padding\_left}, padding_right\text{padding\_right}, padding_top\text{padding\_top}, padding_bottom\text{padding\_bottom}, padding_front\text{padding\_front}, padding_back\text{padding\_back})

Shape:
  • 输入: (N,C,Din,Hin,Win)(N, C, D_{in}, H_{in}, W_{in})(C,Din,Hin,Win)(C, D_{in}, H_{in}, W_{in}).

  • 输出: (N,C,Dout,Hout,Wout)(N, C, D_{out}, H_{out}, W_{out})(C,Dout,Hout,Wout)(C, D_{out}, H_{out}, W_{out}), 其中

    Dout=Din+前填充+后填充D_{out} = D_{in} + \text{前填充} + \text{后填充}

    Hout=Hin+上填充+下填充H_{out} = H_{in} + \text{上填充} + \text{下填充}

    Wout=Win+左填充+右填充W_{out} = W_{in} + \text{左填充} + \text{右填充}

示例:

>>> 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.]]]]])
优云智算