Ravaal
Ravaal

Reputation: 3359

How do I make model.fit(...) print one epoch at a time with keras?

My epochs come out one by one like so-

Epoch 1/50
33148/33148 [==============================] - 1s - loss: 13.3329 - acc: 0.1728

Epoch 2/50
33148/33148 [==============================] - 1s - loss: 13.3329 - acc: 0.1728

Epoch 2/50
33148/33148 [==============================] - 1s - loss: 13.3329 - acc: 0.1728

It holds the previous epoch on the screen. Is there a way that I can just see them pop up and delete the previous epoch?

Upvotes: 1

Views: 5567

Answers (1)

sunil manikani
sunil manikani

Reputation: 320

BaseLogger and ProgbarLogger callbacks kick in by default and therefore you see such output. These callback are automatically applied to every Keras model. The History object gets returned by the fit method of models. You need to catch hold of that object and then configure the behavior (pop-up and delete) you want.

hist = model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=nb_epoch,
           verbose=2, validation_data=(X_test, Y_test))

# Then explore the hist object
hist.history #gives you a dictionary
hist.epoch #gives you a list

Upvotes: 1

Related Questions