How to resume training of a model?

I have not GPU support so it often happens that my model takes hours to train. Can I train my model in batches , for example if I want to have 100 epochs for my model,but due to power cut my training stops(at 50th epoch) but when I retrain my model I want to train it from where it was left (from 50th epoch).

It would be much appreciated if anyone can explain it by some example.

• This is possible with most (all?) mainstream deep learning frameworks by simply storing the model every N training iterations and checking for the last stored model before starting the training. Which framework are you using? – ncasas Oct 16 '17 at 17:56
• I am using tensorflow – Berry Oct 16 '17 at 18:27
• @ncasas could you please give how to do the same using keras ? – user2351509 Apr 7 '19 at 17:23
• A simple google search leads you to the appropriate information. – ncasas Apr 8 '19 at 11:15

With tensorflow, currently the most straightforward and easy way to get persistence for your model is to use a tf.train.MonitoredTrainingSession. You just need to use it instead the normal tf.Session() that is frequently used. This an illustrative Python snippet:
with tf.train.MonitoredTrainingSession(checkpoint_dir='/tmp/mymodel',

With this, your model is automagically saved every 600 secs in /tmp/mymodel and restored the next time you restart the program.