cross-correlation(互相關、交叉相關):
Coutj 第j個輸出Channel(或由第j個Filter輸出)
對於每個Coutj (或每個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/Filter 16:Filter Depth 3:Filter H 5:Filter W
torch.Size([33])
#33個out_channels/Filter bias