ZeroPad3d¶ class torch.nn.ZeroPad3d(padding)[source]¶ 在输入张量的边界使用零填充。 对于 N 维填充,请使用 torch.nn.functional.pad(). 参数 padding (int, tuple) – 填充大小。如果为 int,则在所有边界使用相同的填充。如果为 6 个 tuple,则使用 (padding_left\text{padding\_left}padding_left, padding_right\text{padding\_right}padding_right, padding_top\text{padding\_top}padding_top, padding_bottom\text{padding\_bottom}padding_bottom, padding_front\text{padding\_front}padding_front, padding_back\text{padding\_back}padding_back) 形状 输入:(N,C,Din,Hin,Win)(N, C, D_{in}, H_{in}, W_{in})(N,C,Din,Hin,Win) 或 (C,Din,Hin,Win)(C, D_{in}, H_{in}, W_{in})(C,Din,Hin,Win). 输出:(N,C,Dout,Hout,Wout)(N, C, D_{out}, H_{out}, W_{out})(N,C,Dout,Hout,Wout) 或 (C,Dout,Hout,Wout)(C, D_{out}, H_{out}, W_{out})(C,Dout,Hout,Wout), 其中 Dout=Din+padding_front+padding_backD_{out} = D_{in} + \text{padding\_front} + \text{padding\_back}Dout=Din+padding_front+padding_back Hout=Hin+padding_top+padding_bottomH_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}Hout=Hin+padding_top+padding_bottom Wout=Win+padding_left+padding_rightW_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}Wout=Win+padding_left+padding_right 示例 >>> m = nn.ZeroPad3d(3) >>> input = torch.randn(16, 3, 10, 20, 30) >>> output = m(input) >>> # using different paddings for different sides >>> m = nn.ZeroPad3d((3, 3, 6, 6, 0, 1)) >>> output = m(input)