ConvTranspose2d

class ConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, conv_mode='cross_correlation', compute_mode='default', **kwargs)[源代码]

对输入张量进行二维转置卷积。

该模块也称为反卷积或微步卷积。 ConvTranspose2d 可以看作是 Conv2d 操作对自身输入的梯度。

卷积通常降低了输入的大小,而转置卷积工作方式完全相反,在相同的连接方式下,它对较小的输入进行放大来输出。

参数
  • in_channels (int) – 输入数据中的通道数。

  • out_channels (int) – 输出数据中的通道数。

  • kernel_size (Union[int, Tuple[int, int]]) – 空间维度上的权重大小。如果kernel_size 是一个 int, 实际的kernel大小为 (kernel_size, kernel_size).

  • stride (Union[int, Tuple[int, int]]) – 二维卷积运算的步长。默认:1

  • padding (Union[int, Tuple[int, int]]) – 输入数据空域维度两侧的填充(padding)大小。仅支持填充0值。默认:0

  • dilation (Union[int, Tuple[int, int]]) – 二维卷积运算的空洞(dilation)。默认:1

  • groups (int) – 输入输出的通道被划分的组的数量, 以便执行 grouped convolution。当 groups 不为 1, in_channelsout_channels 必须能被``groups``整除, 并且weight的shape应该是``(groups, in_channels // groups, out_channels // groups, height, width)``. 默认值: 1

  • bias (bool) – 是否给卷积的结果添加bias。默认: True conv_mode: 支持 cross_correlation。默认: cross_correlation

  • compute_mode (str) – 当设置 “default” 时, 不会对中间结果的精度有特殊要求。当设置 “float32” 时, “float32” 将被用作中间结果的累加器, 但是只有当输入和输出的dtype是float16时有效。

注解

  • weight 的shape通常是 (in_channels, out_channels, height, width) , 如果groups 不为 1, shape 将是 (groups, in_channels // groups, out_channels // groups, height, width)

  • bias 的shape通常为 (1, out_channels, *1)