卷积核如何将具有 3 个通道的图像转换为多个通道?最后一个论点是什么意思?



我训练了 ResNet50V2 模型,我想知道张量是如何从3通道转换为n通道的。 我的模型为:

model.summary()
Model: "model_9"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_9 (InputLayer)            (None, 164, 164, 3)  0                                            
__________________________________________________________________________________________________
conv1_pad (ZeroPadding2D)       (None, 170, 170, 3)  0           input_9[0][0]                    
__________________________________________________________________________________________________
conv1_conv (Conv2D)             (None, 82, 82, 64)   9472        conv1_pad[0][0]                  
__________________________________________________________________________________________________
pool1_pad (ZeroPadding2D)       (None, 84, 84, 64)   0           conv1_conv[0][0]                 
__________________________________________________________________________________________________
...
...
...
...
...
...
post_relu (Activation)          (None, 6, 6, 2048)   0           post_bn[0][0]                    
__________________________________________________________________________________________________
flatten_9 (Flatten)             (None, 73728)        0           post_relu[0][0]                  
__________________________________________________________________________________________________
dense_9 (Dense)                 (None, 37)           2727973     flatten_9[0][0]                  
==================================================================================================
Total params: 26,292,773
Trainable params: 26,247,333
Non-trainable params: 45,440

第一个卷积层"conv1_conv"有一个过滤器:

filters= layer.get_weights()[2]  #conv1_conv layer
print(layer.name, filters.shape)

输出:

conv1_conv (7, 7, 3, 64)

我不明白的是使(170,170,3)张量转换为(82,82,64)张量的卷积操作。

conv1_conv中的64表明了什么?

您可以将卷积想象成大小为 7 × 7 的滑动窗口在图像上滑动。每个过滤器都采用图像的一个窗口,这里 7 × 7 × 3 个数字 a 将线性投影成单个数字。每个滤波器需要 7*7*3 个参数进行线性投影,并且您有 64 个参数,因此卷积 7 × 7 × 3 × 64 的形状。

卷积的另一个重要属性是步幅:这是窗口移动的步骤。您的窗口大小为 7,图像的宽度和高度为 170,即滑动窗口需要传递 170-7=163 像素。如果使用步幅 2,则表示 163/2=81.5 个窗口,四舍五入为 82。每个窗口都投影有 64 个过滤器,因此形状为 82 × 82 × 64。

最新更新