Pytorch之conv2d


 

 cross-correlation(互相关、交叉相关):

 

 

 

 Cout第j个输出Channel(或由第j个Filter输出) 

对于每个Cout(或每个Filter)和Ni个Kernal构成的滑动窗口来说:

       输出点(neural)(为Kernal滑动位置和Filter的函数)s值为:

              该Filter的第k层  与  input的Kernal滑动位置下的第k层  卷积后累加      +     该Filter的偏置

 

 

 

m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
input = randn(20, 16, 50, 100)
output = m(input)
print(output.shape)
print(m.weight.shape) #weight bias由系统设置初始值,待模式训练修改
print(m.bias.shape)


运行结果:

torch.Size([20, 33, 26, 100])
#20个样本 out_channels(即out_depth,也就是Filter的数目,也是out_Depth) 卷积后的H 卷积后的W

H=取下界{[50+2x4-3x(3-1)-1]/2 +1 }=取下界{26.5}=26
M=取下界{[100+2x2-1x(5-1)-1]/1 +1}=取下界{100}=100

torch.Size([33, 16, 3, 5])
#33个out_channels/F
ilter 16:Filter Depth 3:Filter H 5:Filter W
torch.Size([33])
#33个out_channels/Filter bias


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM