二维卷积
输入的大小: or
输出的大小: or
其中,星号表示有效的2D相互关联运算符;N为batch;C表示channel的数量;H W分别为输入的高度和宽度。
--in_channels (int):输入图像中的通道数。例如,RGB3通道彩色图像,灰度为1.
--out_channels (int):卷积核产生的通道数。也就是卷积核的个数,每一个卷积核产生一个输出通道。
--kernel_size (int或tuple):卷积核的大小。单个数值时,即为方形,还可以(3,5),表示宽3高5.
--stride (int或tuple,可选,默认:1):卷积的步幅。
--padding (int, tuple或str,可选,默认:0):填充到'输入'的所有四个边(一圈)。
--padding_mode(str,可选, 默认值:'zeros'):``'zeros'``, ``'reflect'``, ``'replicate'`` or ``'circular'``.
--dilation (int或tuple,可选,默认值:1):内核元素之间的间距,即卷积核的膨胀率。
--groups (int,可选,默认值:1):从输入通道到输出通道的阻塞连接数。
--bias (bool,可选,默认值:true):如果为“True”,则在输出中添加可学习的偏差。
属性:
weight (Tensor): shape: The values of these weights are sampled from 其中,
bias (Tensor): shape:(out_channels). If :attr:`bias` is ``True``, then the values of these weights are sampled from 其中,
例子:
>>> # With square kernels and equal stride
>>> m = nn.Conv2d(16, 33, 3, stride=2)
>>> # non-square kernels and unequal stride and with padding
>>> m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
>>> # non-square kernels and unequal stride and with padding and dilation
>>> m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
>>> input = torch.randn(20, 16, 50, 100)
>>> output = m(input)