Skip to content

Instantly share code, notes, and snippets.

@joelthchao
Last active July 2, 2017 15:44
Show Gist options
  • Save joelthchao/2fcfe1d9002c387479bd17f6d5fb455f to your computer and use it in GitHub Desktop.
Save joelthchao/2fcfe1d9002c387479bd17f6d5fb455f to your computer and use it in GitHub Desktop.
Keras Callback
from keras.callbacks import ProgbarLogger
class ProgbarLoggerVerbose(ProgbarLogger):
def on_train_begin(self, logs=None):
super(ProgbarLoggerVerbose, self).on_train_begin(logs)
self.verbose = True
log_file = 'path/to/log.txt' # if you don't want to do logging, just leave the kwags unfilled
my_callback = MyCallback(test_x, test_y, log_file=log_file, verbose=True)
model.fit(X, Y, callbacks=[ProgbarLoggerVerbose('samples'), my_callback], verbose=0)
# if you are using fit_generator, change to ProgbarLoggerVerbose('steps')
"""
Output:
Epoch 1/12
60000/60000 [==============================] - 4s - loss: 0.3180 - acc: 0.9019 - val_loss: 0.0798 - val_acc: 0.9761
Epoch 0 acc= 0.9761
Epoch 2/12
60000/60000 [==============================] - 4s - loss: 0.1117 - acc: 0.9664 - val_loss: 0.0500 - val_acc: 0.9831
Epoch 1 acc= 0.9831
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment