I am using pre-trained VGG-16 model for image classification. I am adding custom last layer as the number of my classification classes are 10. I am training the model for 200 epochs.
My question is: is there any way if I randomly stop (by closing python window) the training at some epoch, let's say epoch no. 50 and resume from there? I have read about saving and reloading model but my understanding is that works for our custom models only instead of pre-trained models like VGG-16.
Here is a customised version of ModelCheckpoint that I use to resume training from a given epoch, gist. It will save the epoch and other logs to a corresponding JSON file, it will also check whether to resume the training or not when starting. You need to call
get_last_epoch
and setinitial_epoch
inmodel.fit
in order to resume from that epoch.You can use
ModelCheckpoint
callback to save your model regularly. To use it, pass acallbacks
parameter to thefit
method:Then, later you can load the last saved model. For more customization of this callback take a look at the documentation.