我目前正在阅读关于’CMS-RCNN:用于无约束人脸检测的上下文多尺度区域CNN’的论文,它使用跳跃连接将conv3-3、conv4-3和conv5-3融合在一起,步骤如下所示
提取人脸区域的特征图(在多个尺度上conv3-3、conv4-3、conv5-3),并对其应用RoI-Pooling(即转换为固定高度和宽度)。对每个特征图进行L2归一化。将人脸的特征图(在多个尺度上)进行RoI池化和归一化后进行拼接(创建一个张量)。对人脸张量应用1×1卷积。对人脸张量应用两个全连接层,创建一个向量。
我使用了Caffe,并基于faster-RCNN VGG16制作了一个prototxt,以下部分被添加到原始的prototxt中
# roi pooling the conv3-3 layer and L2 normalize it layer { name: "roi_pool3" type: "ROIPooling" bottom: "conv3_3" bottom: "rois" top: "pool3_roi" roi_pooling_param { pooled_w: 7 pooled_h: 7 spatial_scale: 0.25 # 1/4 }}layer { name:"roi_pool3_l2norm" type:"L2Norm" bottom: "pool3_roi" top:"pool3_roi"}-------------# roi pooling the conv4-3 layer and L2 normalize it layer { name: "roi_pool4" type: "ROIPooling" bottom: "conv4_3" bottom: "rois" top: "pool4_roi" roi_pooling_param { pooled_w: 7 pooled_h: 7 spatial_scale: 0.125 # 1/8 }}layer { name:"roi_pool4_l2norm" type:"L2Norm" bottom: "pool4_roi" top:"pool4_roi"} --------------------------# roi pooling the conv5-3 layer and L2 normalize it layer { name: "roi_pool5" type: "ROIPooling" bottom: "conv5_3" bottom: "rois" top: "pool5" roi_pooling_param { pooled_w: 7 pooled_h: 7 spatial_scale: 0.0625 # 1/16 }}layer { name:"roi_pool5_l2norm" type:"L2Norm" bottom: "pool5" top:"pool5"}# concat roi_pool3, roi_pool4, roi_pool5 and apply 1*1 convlayer { name:"roi_concat" type: "Concat" concat_param { axis: 1 } bottom: "pool5" bottom: "pool4_roi" bottom: "pool3_roi" top:"roi_concat"}layer { name:"roi_concat_1*1_conv" type:"Convolution" top:"roi_concat_1*1_conv" bottom:"roi_concat" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 128 pad: 1 kernel_size: 1 weight_filler{ type:"xavier" } bias_filler{ type:"constant" } }}layer { name: "fc6" type: "InnerProduct" bottom: "roi_concat_1*1_conv" top: "fc6" param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 4096 }}
在训练过程中,我遇到了这样的问题
F0616 16:43:02.899025 3712 net.cpp:757] Cannot copy param 0 weights from layer 'fc6'; shape mismatch. Source param shape is 1 1 4096 25088 (102760448); target param shape is 4096 10368 (42467328).To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.
我无法找出问题所在,如果你能发现一些问题或解释,我需要你的帮助。
非常感谢!!
回答:
你得到的错误信息非常清楚。你试图微调层的权重,但在"fc6"
层上遇到了问题:
你从中复制权重的原始网络的"fc6"
层输入维度为10368。另一方面,你的"fc6"
层的输入维度为25088。如果输入维度不同,你不能使用相同的W
矩阵(即该层的param 0
)。
现在你知道了问题所在,再次查看错误信息:
Cannot copy param 0 weights from layer 'fc6'; shape mismatch. Source param shape is 1 1 4096 25088 (102760448); target param shape is 4096 10368 (42467328).
Caffe无法复制"fc6"
层的W
矩阵(param 0
),其形状与你试图微调的.caffemodel中存储的W
形状不匹配。
你能做些什么?
只需阅读错误信息的下一行:
To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.
只需重命名该层,Caffe将从头开始学习该层的权重(仅限此层)。