1

我目前正在閱讀'CMS-RCNN:基於上下文多尺度區域的CNN無約束人臉檢測'的論文,它使用skip-connection將conv3-3,conv4-3和conv5-3融合在一起,步驟如下所示基於Caffe中的VGG16製作跳躍層連接網絡時出錯

提取臉部區域的特徵映射(多個比例的conv3-3,conv4-3,conv5-3)並應用RoI - 回到它(即轉換爲固定的高度和寬度)。 L2-規格化每個特徵圖。 連接(RoI合併和歸一化)臉部(多個比例)的特徵映射(彼此)(創建一個張量)。 對臉部張量應用1x1卷積。 將兩個完全連接的層應用到面張量,創建一個向量。

我用朱古力並提出基於快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. 

我可以找出哪裏出了問題,如果你能發現一些問題或解釋,我需要你的幫助。

真的很感謝!

回答

1

你得到的錯誤信息很清楚。您正在嘗試微調圖層的權重,但對於"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. 

只需重命名層,和朱古力將從頭學習(僅適用於該層)的權重。