muammar / ml4chem

ML4Chem: Machine Learning for Chemistry and Materials
https://ml4chem.dev
Other
93 stars 15 forks source link

Transfer Learning #19

Open muammar opened 5 years ago

muammar commented 5 years ago
  1. Load in pre-trained weights from a network trained on a large dataset
  2. Freeze all the weights in the lower (convolutional) layers: the layers to freeze are adjusted depending on similarity of new task to original dataset
  3. Replace the upper layers of the network with a custom classifier: the number of outputs must be set equal to the number of classes
  4. Train only the custom classifier layers for the task thereby optimizing the model for smaller dataset.

Loading in a pre-trained model in PyTorch is simple:

from torchvision import models
model = model.vgg16(pretrained=True)

Source: https://towardsdatascience.com/transfer-learning-with-convolutional-neural-networks-in-pytorch-dd09190245ce

I think the pretrained keyword argument is something that has to do with the vgg16 model but should not be complicated to implement.