当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python PyTorch ConstantPad3d用法及代码示例


本文简要介绍python语言中 torch.nn.ConstantPad3d 的用法。

用法:

class torch.nn.ConstantPad3d(padding, value)

参数

padding(int,tuple) -填充的大小。如果是 int ,则在所有边界中使用相同的填充。如果是 6- tuple ,则使用( )

用一个常数值填充输入张量边界。

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

形状:
  • 输入:

  • 输出: ,其中

    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}

例子:

>>> m = nn.ConstantPad3d(3, 3.5)
>>> input = torch.randn(16, 3, 10, 20, 30)
>>> output = m(input)
>>> # using different paddings for different sides
>>> m = nn.ConstantPad3d((3, 3, 6, 6, 0, 1), 3.5)
>>> output = m(input)

相关用法


注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.nn.ConstantPad3d。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。