Fine tuning GoogLeNet - where/what to set lr_mult?

948 views
Skip to first unread message

Thomas Wood

unread,
Jun 30, 2016, 8:56:49 AM6/30/16
to Caffe Users
Hi
I am wondering if anybody has successfully fine tuned GoogLeNet for a completely different task from the 1000 ImageNet classes?
Following the logic of the FlickrStyle tutorial, you should set a different learning rate for some layers.
I am assuming the LR should be boosted 10x in the final classifier layers. Did you also do this? Any chance of sharing your prototxt please?
Should I also set lr_mult to 0 in the first layers? Should all 3 classifiers have lr_mult = 10?

I have some problems with accuracy, as I have tried the simple recipe but I find that my auxiliary classifiers perform better than the final classifier. Maybe it's due to my training data, or using the wrong LR. I'm sharing my prototxt and I'm interested in hearing anyone else's experiences!

Thanks

Tom
fine_tune_googlenet_no_boost_last_layer

Hieu Do Trung

unread,
Jul 2, 2016, 12:41:54 AM7/2/16
to Caffe Users
"Should I also set lr_mult to 0 in the first layers? Should all 3 classifiers have lr_mult = 10?"

I think so, you should change [learning rate - names - number of outputs] for all these layers:
loss3/classifier, loss2/classifier, loss1/classifier

Attached file is a template prototxt file that someone shared on this group and I changed a bit to adapt to my need.
You should search for #num_output and change it to your number.
Also do the same for the #train_batch, #test_batch, and the proper path for *_lmdb, *binaryproto files - in the sample prototxt file.

This is the train_val.prototxt file, so you should change the deploy file accordingly.
train_val_googlenet_template.prototxt

Thomas Wood

unread,
Jul 5, 2016, 9:30:38 AM7/5/16
to Caffe Users
Thank you Hieu.
 
Your file is the same as one of the prototxts I have been working with - I also set lr_mult=10 for the three output layers. Although I also set lr_mult = 0 in the first layers, since they only perform edge detection.

So I'm wondering if you did any tests for accuracy on the two auxiliary classifiers? In my case, they performed better than the main classifier.

Joshua N Stanton

unread,
Jul 6, 2016, 4:21:46 AM7/6/16
to Caffe Users
i just get error of size on layer inception4a 1x1 saying it expects 192 output where i have 406 images but when i check th eprtottxt file i ahve set num_output to 406 according to the number of images im flicerk training on... any idea why??

Thomas Wood

unread,
Jul 6, 2016, 5:19:53 AM7/6/16
to Caffe Users
You have 406 images? or 406 classes?
The num_output refers to how many classes you are trying to classify.
So if you are trying to make a cat vs dog classifier, you would have 406 images approximately evenly split into 2 classes, cat and dog. Then num_output is 2.
(in practice you might split into 3 classes, cat, dog and anything else, and then num_output=3)

You need to take the original GoogLeNet train_val.prototxt (you can find it in your Caffe source code) and go to these 3 layers:

loss1/classifier
loss2/classifier
loss3/classifier

For each of them, you need to
1. rename the layer so that Caffe won't try to copy the weights from the original GoogLeNet into it
2. update num_output to the number of classes you're trying to recognise.
Reply all
Reply to author
Forward
0 new messages