import torch
x = torch.randn(3,1,5,4)
print(x)
conv = torch.nn.Conv2d(1,4,(2,3))
res = conv(x)
print(res.shape) # torch.Size([3, 4, 4, 2])
输入:x[ batch_size, channels, height_1, width_1 ]batch_size
,一个batch中样本的个数 3channels
,通道数,也就是当前层的深度 1height_1
, 图片的高 5width_1
, 图片的宽 4
卷积操作:Conv2d[ channels, output, height_2, width_2 ]channels
,通道数,和上面保持一致,也就是当前层的深度 1output
,输出的深度 4【需要4个filter】height_2
,卷积核的高 2width_2
,卷积核的宽 3
Conv2D产生的weight和biasweight
:(out_channels, in_channels, ker_size, ker_size)
:::tips
假定给定weight: (64, 1, 3, 3)
, 则反推出input:(batch_size, 1, height, width)
:::
输出:res[ batch_size,output, height_3, width_3 ]batch_size
,,一个batch中样例的个数,同上 3output
, 输出的深度 4height_3
, 卷积结果的高度 4width_3
,卷积结果的宽度 2