转自:https://blog.csdn.net/m0_37586991/article/details/87855342
import torch
x
= torch
.randn
(2,1,7,3)
conv
= torch
.nn
.Conv2d
(1,8,(2,3))
res
= conv
(x
)
print(res
.shape
)
输入: x [batch_size,channels,height_1,width_1] batch_size 一个batch中样例的个数 2 channels 通道数,也就是当前层的深度 1 height_1, 图片的高 7 width_1, 图片的宽 3
Conv2d的参数 [channels, output,height_2,width_2] channels, 通道数,和上面保持一致,也就是当前层的深度 1 output 输出的深度 8 height_2,过滤器filter的高 2 width_2,过滤器filter的宽 3
输出: res [batch_size, output,height_3,width_3] batch_size,一个batch中样例的个数, 同上 2 output 输出的深度 8 height_3,卷积结构的高度 6=height_1-height_2+1=7-2+1 width_3, 卷积结果的宽度 1=width_1-width_2+1=3-3+1