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_channels
和out_channels
必须都能被groups
整除。例如,在 groups=1 的情况下,所有输入都会与所有输出进行卷积。
在 groups=2 的情况下,操作相当于有两个卷积层并排,每个层看到一半的输入通道并产生一半的输出通道,然后两者随后进行拼接。
在 groups=
in_channels
的情况下,每个输入通道都会与其自己的过滤器集(大小为 )进行卷积。
注意
The
padding
argument effectively addsdilation * (kernel_size - 1) - padding
amount of zero padding to both sizes of the input. This is set so that when aConv1d
and aConvTranspose1d
are initialized with same parameters, they are inverses of each other in regard to the input and output shapes. However, whenstride > 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 thatoutput_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 settingtorch.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
- 形状:
输入: 或
输出: 或 ,其中
- 变量:
权重(张量)- 模块的学得权重,形状为 。这些权重的值从 中采样,其中
偏置(张量)- 模块的学得偏置,形状为(out_channels)。如果bias
是True
,则这些权重的值从 中采样,其中