Skip to content

Instantly share code, notes, and snippets.

@gurucharanmk
Created March 11, 2020 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gurucharanmk/0d5fa4941b0be8ed6f45faec489fe4c4 to your computer and use it in GitHub Desktop.
Save gurucharanmk/0d5fa4941b0be8ed6f45faec489fe4c4 to your computer and use it in GitHub Desktop.
Code snippet for medium article
#Mixed precision model to train
learn = cnn_learner(dls, resnet18, pretrained=True, metrics=[accuracy_multi]).to_fp16()
#Train only the classifier using one cycle policy, with default optimizer(ADAM) and learning rate.
learn.fit_one_cycle(4)
#Save the trained model
learn.save('stage_1')
#Unfreeze the model, now entire model is available for training
learn.unfreeze()
#Find optimal leaning rate
learn.lr_find()
#Train the entire model with variable learning rate across the layers
learn.fit_one_cycle(4, slice(1e-6, 1e-4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment