Dimension mismatch when fine-tuning caffe with pre trained AlexNet model.

421 views
Skip to first unread message

Md. Asif Khan

unread,
Jun 24, 2015, 2:06:20 AM6/24/15
to caffe...@googlegroups.com
Hi,
  I have added a new layer after first fully connected layer in reference AlexNet model.In this I am selecting 2048 out of 4096 features. Rest of the network is exactly similar to AlexNet. Now I want to use pretrained model to fine tune weights of all the layers. When I try to do so, I get the following error:

       net.cpp:791] Check failed: target_blobs[j]->height() == source_layer.blobs(j).height() (2048 vs. 4096)
 

Will be highly grateful for any suggestion or ideas that can help in resolving the issue. 

Evan Shelhamer

unread,
Jun 30, 2015, 1:41:59 AM6/30/15
to Md. Asif Khan, caffe...@googlegroups.com
This is explained in the fine-tuning tutorial: http://caffe.berkeleyvision.org/gathered/examples/finetune_flickr_style.html. If you redefine a layer, you should change its name or else Caffe will try to load the original weights. This will obviously fail since you changed the dimension.

Evan Shelhamer

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/9b411df1-13ac-4f8a-8e83-2914a78539e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Md. Asif Khan

unread,
Jun 30, 2015, 2:08:34 AM6/30/15
to caffe...@googlegroups.com, m.asi...@lnmiit.ac.in
Hi,
Thanks for your reply.I tried doing so but it didn't work.
  In my case the situation is different. I have defined a new layer with functionality of feature selection. This new layer is inserted between first and second fully connected layer. Now my network has 9 layers(5 Conv. Layer , 2 FC Layer ,1 mylayer and 1 softmax layer).
I want to use caffenet pretrained model for all the remaining layer excluding mylayer.

Md. Asif Khan

unread,
Jun 30, 2015, 2:33:53 AM6/30/15
to caffe...@googlegroups.com
My question is how can I initialize remaining network using pretrained model and skip the layer defined by me.

For defining new layer I followed https://github.com/BVLC/caffe/wiki/Development

Changes in prototxt file
........
.......
layers {
name: "discrim"
type:  FEATURE_SELECTION
bottom: "fc6"
top: "discrim"
discrim_param{
beta:0.5
}
}
layers{
name: "fc7" 
.........
........

The output of my layer is dependent on beta. For beta:1 it is 4096.

Reply all
Reply to author
Forward
0 new messages