+1 vote
in AI and Deep Learning by (3.9k points)
edited by

I want to save the history to a file, in Keras I have model.fit

history = model.fit(Q_train, W_train,
                     validation_data=(Q_test, W_test))

2 Answers

0 votes
by (46.1k points)
edited by

You can save the model history by this:

with open('/trainHistoryDict', 'wb') as file_pi:
        pickle.dump(history.history, file_pi)

Happy Learning.  

Want to learn AI? Read this extensive artificial intelligence tutorial!

+4 votes
by (10.9k points)
edited by

You can try this code:

import json

history = model.fit(Q_train, W_train, epochs=5, batch_size=batch_size,validation_split=0.1)

with open('myfile.json', 'w') as file:

    json.dump(history.history, file)

Welcome to Intellipaat Community. Get your technical queries answered by top developers !