include_top=False, classes=2: error message
leosilvestre opened this issue · 1 comments
I'm trying to do a binary classification with imagenet weights and set include_top=False and classes = 2, but I receive the following error message:
If using weights
as imagenet with include_top
as true, classes
should be 1000
I think that the condition ( if weights == 'imagenet' and classes != 1000) or the message is wrong. Which one is correct?
Thank you!
Tensorflow Version
Please replace this line with Tensorflow version you are using.
Keras Version
Please replace this line with Keras version you are using.
Keras-squeezenet Version
Please replace this line with Keras-squeezenet version you are using.
Bug reports:
Please replace this line with a brief summary of your issue AND if reporting a build issue include the link from:
Code Sample:
Please replace this line with a code sample to replicate the issue.
I just came here randomly. But I think I can answer your question:
When using a pretrained model in transfer learning, one should remove the top layer and replace it with another FC layer that has neurons at the size of the new task's class numbers. So in your case, using includeTop=True is wrong. You should remove the top layer by assigning includeTop to False and add a Dense layer with 2 neurons to the model. Then you need to retrain your network on the new dataset (and probably freeze all other layers).