Reputation: 318
I need explanation of save best only option of ModelCheckpoint. If I have a code like this
model.compile(optimizer='adam', loss='mse', metrics=['accuracy'])
cp = [ModelCheckpoint(filepath=path+"/model-lstmMulti", verbose=1, save_best_only=True)]
history_callback = model.fit(X, y, epochs=350, verbose=1, callbacks=cp)
and then I want to see the accuracy of that best model:
acc_history = history_callback.history["acc"]
np.savetxt(path+"/acc_history.txt", np.asarray(acc_history))
I got the array ie. accuracy of the models of all epochs. Why I don't get only one value - accuracy of the best model?
Upvotes: 2
Views: 1399
Reputation: 720
ModelCheckpoint
is a callback function used to save model file (h5) after epochs. It doesn't affect the return history of fit()
method. Just use np.max
to get the best acc from acc history will do your job.
Upvotes: 1