Skip to content

Instantly share code, notes, and snippets.

@GiulioCMSanto
Created September 22, 2019 16:05
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 GiulioCMSanto/b5491b7ba47e8bdc8598c96271da0b83 to your computer and use it in GitHub Desktop.
Save GiulioCMSanto/b5491b7ba47e8bdc8598c96271da0b83 to your computer and use it in GitHub Desktop.
Classifying Flowers With Transfer Learning
#Extract the class_to_idx transformation
model.class_to_idx = train_data.class_to_idx
#Put the model in CPU mode to allow predictions without having CUDA
model.to('cpu')
#Create the checkpoint
checkpoint = {'input_size':25088,
'output_size':102,
'hidden_layers':[each.out_features for each in classifier.hidden_layers],
'drop_p':0.2,
'state_dict':model.state_dict(),
'class_to_idx': model.class_to_idx}
filepath = 'checkpoint.pth'
#Save the model
torch.save(checkpoint, filepath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment