我目前正在阅读关于“CMS-RCNN:基于上下文的多尺度无约束人脸检测CNN”的论文,它使用跳过连接将conv5 3-3、con4-3和con5-3融合在一起,步骤如下所示
提取面部区域的特征图(在多尺度上为卷积3-3、卷积4-3、卷积5-3),并对其应用RoI池(即转换为固定的高度和宽度)。L2-标准化每个特征地图。将面部(多尺度)的(RoI池和规范化)特征映射相互连接(创建一个张量)。对脸部张量进行1x1卷积。将两个完全连接的层应用于面部张量,创建一个矢量。
我使用了caffe,并在快速RCNN VGG16的基础上制作了一个原型,下面的部分被添加到原来的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]不能从层‘fc6’复制0权值;形状不匹配。源仿真器形状为1 4096 25088 (102760448);目标仿射形状为4096 10368 (42467328)。要从零开始学习该层的参数,而不是从保存的网络中复制,请重命名该层。
我可以找出哪里出了问题,如果你能发现问题或解释的话,我需要你的帮助。
真的很感激!!
发布于 2017-06-19 06:35:33
您得到的错误消息非常清楚。您正在尝试微调层的权重,但是对于"fc6"层,您有一个问题:
您复制的原始网的权重有"fc6"层,输入维数为10368。另一方面,"fc6"层的输入维数为25088。如果输入维度不同,则不能使用相同的W矩阵(也称为此层的param 0 )。
现在您已经知道了问题所在,请再次查看错误消息:
无法从层‘fc6’复制param 0权重;形状不匹配。源仿真器形状为1 4096 25088 (102760448);目标仿射形状为4096 10368 (42467328)。
Caffe无法复制W矩阵(param 0)的"fc6"层,其形状与存储在.caffemodel中的W形状不匹配。
你能做什么?
只需阅读错误消息的下一行:
要从零开始学习该层的参数,而不是从保存的网络中复制,请重命名该层。
只需重命名该层,caffe将从零开始学习权重(仅用于此层)。
https://stackoverflow.com/questions/44622846
复制相似问题