Winston Dodson
Winston Dodson

Reputation: 29

Saving then reusing CNN models - preserving initializations

I wish to repeat a series of image classification experiments by reusing a CNN with the same CNN with identical hyperparameters especially initializations. So, if I save a model after I have instantiated it and before I train it, does that also save the initializations so I then reload it later and train with a different data set and labels, does it start this new model with the same hyperparameters and initializations as the first model I trained with the first data set/classification labels? I am currently using fastai which is, of course, a library/set of API's, built on Pythorch but I think that everyone would be helped with a more general explanation that covers all CNN's using any library.

I expect an answer that says, "after this point in the workflow creating a CNN, the model is initialized and if you save it at this point, you can reload it later and use the same hyperparameters and initializations in your next model."

Upvotes: 0

Views: 155

Answers (1)

Tree
Tree

Reputation: 31391

you can save the learner as soon it is created.

Example:

learn = cnn_learner(data,models.resnet34,metrics=error_rate)
learn.save('init')

later on:

learn.load('init)

Upvotes: 1

Related Questions