我目前正在阅读“CMS-RCNN:用于无约束人脸检测的基于上下文多尺度区域的 CNN”的论文,它使用跳跃连接将 conv3-3、conv4-3 和 conv5-3 融合在一起,步骤如下所示
提取人脸区域的特征图(多个尺度 conv3-3、conv4-3、conv5-3)并对其应用 RoI-Pooling(即转换为固定的高度和宽度)。 L2-标准化每个特征图。 将面部(多个尺度)的(RoI 池化和归一化)特征图相互连接(创建一个张量)。 对面部张量应用 1x1 卷积。 将两个完全连接的层应用于面张量,创建一个向量。
我使用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 conv
layer {
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
),其形状与 的形状不匹配W
存储在您正在尝试微调的 .caffemodel 中。
你能做什么?
只需阅读错误消息的下一行:
To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.
只需重命名该层,caffe 就会从头开始学习权重(仅适用于该层)。
关于machine-learning - caffe中基于VGG16制作跳层连接网络出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44622846/