Given a trained Keras model, is there a way to check how many epochs were used to train it? For example, print model.nb_epoch
.
When training a model, say, 20 epochs at a time this will help figure out how many total epochs it has been trained on.
I guess you're attempting to perform some sort of gridsearch to find the optimum training parameters to use?
As far as I am aware, there is nothing about the fitting of the NN stored in the saved models. You'd have to do this manually.
Okay, thanks. I guess I'll have to track it manually.
Any thoughts on adding model.nb_epoch
to the class?
Any thoughts on adding model.nb_epoch to the class?
The number of "epochs" a model was trained for only makes sense in a few situations. It assume you use "epochs", but what if you train with randomly generated batches out of a data generator? What if you use several datasets? What if you use pre-training? etc.
So: no, we won't do that. A model is just a state.
That makes sense. Thanks for the response @fchollet!
I could still see situations where it would be helpful to see stats on the number of epochs from a model:
you can save the length of your model's history when training it.
r = model.fit(X_train,y_train,epochs=5)
n_epochs = len(r.history['loss'])
Most helpful comment
you can save the length of your model's history when training it.
r = model.fit(X_train,y_train,epochs=5)
n_epochs = len(r.history['loss'])