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

Modify fc8 layer in a VGG19 neural network #40

Open
cacophrene opened this issue Aug 25, 2018 · 3 comments
Open

Modify fc8 layer in a VGG19 neural network #40

cacophrene opened this issue Aug 25, 2018 · 3 comments

Comments

@cacophrene
Copy link

Hi,

I am using a pretrained VGG19. I would like to adjust the final FC layer fc8 to fit a different number of classes, then retrain the final layer and use to perform prediction on a specific set of images. However, I do not see how I can interact with the Fnn.Model.t structure, or how to filter the parameters to recover from the Fnn.Model.load function. Would you be able to help with that?

Many thanks!

@LaurentMazare
Copy link
Owner

Hi,
Sorry for the very delayed answer. I would suggest hacking the Fnn.Model.load function to fit your use case, for example by discarding the last layer weights based on their name.
For the retrain bit, note that Fnn.Model.fit has some explicit_vars parameter that could help, or maybe you want once again to filter the variables based on their names.
If this works properly for you, we could consider adding some more general support for this, e.g. by adding some kind of regexp to exclude some weights from being loaded.

@cacophrene
Copy link
Author

Hi,

Sorry for taking so much time to get back to you and thanks a lot for your help with this! I keep this in mind. Actually, due to time constraints with my project I had to move back to Python and Keras. That said, I will keep investigating this precious binding once I have more time. Thanks again!

@LaurentMazare
Copy link
Owner

Thanks for the update, it certainly makes sense to use Python/Keras under time constraints. Let me know if you want some help trying this in OCaml at some point.
For what it's worth I have been working recently on some OCaml bindings for PyTorch. I added yesterday some example showing how to retrain the FC layer of a ResNet-18 network (based on this PyTorch tutorial in Python). I will add some detailed tutorial on how this works soon.
All this is pretty much a work in progress but the bindings already feel nicer to use that the TensorFlow bindings.

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