快捷键

ConvTranspose1d ¬

class torch.nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros', device=None, dtype=None)[source][source]

在由多个输入平面组成的输入图像上应用 1D 转置卷积算子。

此模块可以看作是 Conv1d 相对于其输入的梯度。它也被称为分数步长卷积或反卷积(尽管它不是真正的反卷积操作,因为它不计算卷积的真正逆)。有关更多信息,请参阅此处可视化以及反卷积网络论文。

此模块支持 TensorFloat32。

在某些 ROCm 设备上,当使用 float16 输入时,该模块将使用不同的精度进行反向操作。

  • stride 控制交叉相关步长。

  • padding 控制两侧隐式零填充的数量。 dilation * (kernel_size - 1) - padding 点数。详情请见下文注释。

  • output_padding 控制输出形状一侧额外增加的大小。详情请见下文注释。

  • dilation 控制内核点之间的间距;也称为à trous 算法。描述起来比较困难,但这里有一个很好的可视化链接,展示了 dilation 的作用。

  • groups 控制输入和输出之间的连接。 in_channelsout_channels 必须都能被 groups 整除。例如,

    • 在 groups=1 的情况下,所有输入都会与所有输出进行卷积。

    • 在 groups=2 的情况下,操作相当于有两个卷积层并排,每个层看到一半的输入通道并产生一半的输出通道,然后两者随后进行拼接。

    • 在 groups= in_channels 的情况下,每个输入通道都会与其自己的过滤器集(大小为 out_channelsin_channels\frac{\text{out\_channels}}{\text{in\_channels}} )进行卷积。

注意

The padding argument effectively adds dilation * (kernel_size - 1) - padding amount of zero padding to both sizes of the input. This is set so that when a Conv1d and a ConvTranspose1d are initialized with same parameters, they are inverses of each other in regard to the input and output shapes. However, when stride > 1, Conv1d maps multiple input shapes to the same output shape. output_padding is provided to resolve this ambiguity by effectively increasing the calculated output shape on one side. Note that output_padding is only used to find output shape, but does not actually add zero-padding to output.

注意

In some circumstances when using the CUDA backend with CuDNN, this operator may select a nondeterministic algorithm to increase performance. If this is undesirable, you can try to make the operation deterministic (potentially at a performance cost) by setting torch.backends.cudnn.deterministic = True . Please see the notes on Reproducibility for background.

参数:
  • in_channels (int) – Number of channels in the input image

  • out_channels (int) – Number of channels produced by the convolution

  • 卷积核大小(整数或元组)- 卷积核的大小

  • 步长(整数或元组,可选)- 卷积的步长。默认:1

  • 填充(整数或元组,可选)- dilation * (kernel_size - 1) - padding 将在输入的两侧添加零填充。默认:0

  • 输出填充(整数或元组,可选)- 添加到输出形状一侧的额外大小。默认:0

  • groups(int,可选)- 从输入通道到输出通道的阻塞连接数。默认:1

  • bias(bool,可选)- 如果 True ,则向输出添加可学习的偏置。默认: True

  • dilation(int 或 tuple,可选)- 卷积核元素之间的间距。默认:1

形状:
  • 输入: (N,Cin,Lin)(N, C_{in}, L_{in})(Cin,Lin)(C_{in}, L_{in})

  • 输出: (N,Cout,Lout)(N, C_{out}, L_{out})(Cout,Lout)(C_{out}, L_{out}) ,其中

    Lout=(Lin1)×stride2×padding+dilation×(kernel_size1)+output_padding+1L_{out} = (L_{in} - 1) \times \text{stride} - 2 \times \text{padding} + \text{dilation} \times (\text{kernel\_size} - 1) + \text{output\_padding} + 1
变量:
  • 权重(张量)- 模块的学得权重,形状为 (in_channels,out_channelsgroups,(\text{in\_channels}, \frac{\text{out\_channels}}{\text{groups}}, kernel_size)\text{kernel\_size}) 。这些权重的值从 U(k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k}) 中采样,其中 k=groupsCoutkernel_sizek = \frac{groups}{C_\text{out} * \text{kernel\_size}}

  • 偏置(张量)- 模块的学得偏置,形状为(out_channels)。如果 biasTrue ,则这些权重的值从 U(k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k}) 中采样,其中 k=groupsCoutkernel_sizek = \frac{groups}{C_\text{out} * \text{kernel\_size}}


© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源