Reputation: 31
I train CNN model with keras library with numbers of epoch is 25. Can I run model in first time with 10 epochs then save model with these lines of code:
model.fit_generator(training_set,
steps_per_epoch = 100000,
epochs = 10,
validation_data = test_set,
validation_steps = 40000)
from keras.models import load_model
model.save('my_model.h5')
Then I restart python and continue to run the next 15 epochs with the same dataset like the code bellow:
model = load_model('my_model.h5')
model.fit_generator(training_set,
steps_per_epoch = 100000,
epochs = 15,
validation_data = test_set,
validation_steps = 40000)
Is it sufficient to continue training ? Or I have to do any other step to continue the job. I am very appreciated with any support.
Upvotes: 1
Views: 1681
Reputation: 56347
Yes this is okay, model.save
saves the weights, model architecture, and optimizer state, so you can resume training with no problems.
Upvotes: 1