caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Re-train the last layers of a pre-trained model

Open Romainpaulus opened this issue 12 years ago • 2 comments

I have followed this tutorial to extract features at the fc7 layer of the pre-trained alexNet, and I want to re-use these features to train the last fully-connected layers of alexNext. I have tried to follow this tutorial and used the newly extracted features instead of the train and val leveldb, removed all the layers up to fc7, changed the type of fc7 to DATA with the correct source, and the network is running but not training anything (loss function down to 0 after the first iteration). I suspect that the extracted features do not include labels (I have included them in the first tutorial, they are not all equal to 0), I guess that's why training is not working.

Is this the correct way to re-train the last layers of a pre-trained network? If yes, how can I include labels to the extracted features? If not, what is the correct way to do this?

Romainpaulus avatar Jul 07 '14 18:07 Romainpaulus

You could also reuse the entire AlexNet model and only change the name and the amount of outputs of the fc7 layer. After doing so just call $TOOLS/finetune_net.bin. Your solutions sounds right too but a bit overcomplicated. For a more detailed description of the steps go there: #644 I had the same problem more or less.

wendlerc avatar Jul 09 '14 15:07 wendlerc

Thanks, I just saw that I can also put the learning rate of some layers to 0 if I don't want to change them. This will work too!

Romainpaulus avatar Jul 09 '14 23:07 Romainpaulus