本篇内容主要讲解“Pytorch:Conv2d卷积前后尺寸怎么设置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Pytorch:Conv2d卷积前后尺寸怎么设置”吧!
Pytorch:Conv2d卷积前后尺寸
Conv2d参数
尺寸变化
卷积前的尺寸为(N,C,W,H) ,卷积后尺寸为(N,F,W_n,H_n)
W_n = (W-F+S+2P)/S 向下取整
H_n = (H-F+S+2P)/S
示例
# m = nn.Conv2d(16, 33, 3, stride=2)# non-square kernels and unequal stride and with paddingm = 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)print(input.size())output = m(input)print(output.size())
反卷积(转置卷积)Conv2DTranspose 输出的尺寸大小
keras的Conv2DTranspose
The size of the input feature map: (N, N)Conv2dTranspose(kernel_size=k, padding, strides=s)padding=‘same' ,输出尺寸 = N × spadding=‘valid',输出尺寸 = (N-1) × s + k
到此,相信大家对“Pytorch:Conv2d卷积前后尺寸怎么设置”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!