Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fine tuning ... #24

Closed
MyVanitar opened this issue Jul 13, 2017 · 8 comments
Closed

Fine tuning ... #24

MyVanitar opened this issue Jul 13, 2017 · 8 comments

Comments

@MyVanitar
Copy link

MyVanitar commented Jul 13, 2017

Hello,

You have provided the pre-trained model of VOC. I have a small dataset with 2 classes, which I annotated based on VOC and I want to fine-tune it. Would you please guide me through the process?

@shuuchen
Copy link

@MyVanitar
Copy link
Author

Thank you but that one is a classification task but yours is a semantic segmentation.
Besides, may I ask you how much is the best accuracy of this model on VOC evaluation?

@shuuchen
Copy link

I am not the author and I dont know the accuracy.
For fine-tuning, I think the methods are similar.
Just use your training data to fine-tune the layers you want and freeze the other layers.

@MyVanitar
Copy link
Author

MyVanitar commented Jul 19, 2017

I think this layer should be truncated and fine-tuned with a different number of classes:

model.add(Convolution2D(21, 1, 1, activation='linear', name='fc-final'))

otherwise the rest of the code uses the pre-trained weights to train on a new dataset, but with 21 classes.

@MyVanitar
Copy link
Author

Also this layer inside context:

model.add(Convolution2D(21, 1, 1, name='ct_final'))

This makes it tricky for me, but the author certainty can do or give some tips.

@nicolov
Copy link
Owner

nicolov commented Jul 19, 2017

Correct, first the number of features in those two layers to 2. Then, follow the keras blog to load the pretrained weights for all the other layers. If you want, you can freeze those layers, and then you can start training

@MyVanitar
Copy link
Author

MyVanitar commented Jul 19, 2017

Actually you load the pre-trained model already in the code, as I see. Am I right?

Therefore I should pop or delete these two layers and add new ones OR freeze the weights just before these layers to be trained with the new class parameter.

In case of freezing, may I ask you I should freeze till what layer number?

Because these are two different layers in two different locations I'm little bit confused and I need your help. what I know is classification models which we only deal with one layer and examples are all about this, not like the situation we have here

@nicolov
Copy link
Owner

nicolov commented Aug 27, 2017

Start by changing the model definitions to reduce the output dimension to 2 (the number of classes you want). This function will then error out: change it so that you don't load the weights for the last layer.

You're now ready to train on your dataset. You may want to look into freezing the weights for the existing layers, but it may not be required.

@nicolov nicolov closed this as completed Aug 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants