快捷鍵

ReflectionPad3d

class torch.nn.ReflectionPad3d(padding)[原始碼][原始碼]

使用輸入邊界的反射來填充輸入張量。

對於 N 維填充,使用 torch.nn.functional.pad()

參數

padding ( int, tuple) – 填充(padding)的大小。如果為 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)
  • 輸入 (Input): (N,C,Din,Hin,Win)(N, C, D_{in}, H_{in}, W_{in}) or (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+padding_front+padding_backD_{out} = D_{in} + \text{padding\_front} + \text{padding\_back}

    輸出高度 = 輸入高度 + 上邊距 + 下邊距

    輸出寬度 = 輸入寬度 + 左邊距 + 右邊距

範例

>>> 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.]]]]])

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得適合初學者和進階開發者的深入教學

檢視教學

資源

尋找開發資源並取得問題解答

檢視資源