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

include_top=False, classes=2: error message #23

Open
leosilvestre opened this issue Jul 19, 2019 · 1 comment
Open

include_top=False, classes=2: error message #23

leosilvestre opened this issue Jul 19, 2019 · 1 comment

Comments

@leosilvestre
Copy link

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.

@cmehrshad
Copy link

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).

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

2 participants