self.classifier.fit(x_tr, y_tr, batch_size=self.batch_size, nb_epoch=self.nb_epoch,
verbose=self.print_status, validation_data=(x_te, y_te), callbacks=[keras.callbacks.ProgbarLogger()])
import cPickle as pickle
# ...
results = model.fit(...) # results.history is dict of loss, acc, val_loss, and val_acc
# ...
with open('results.pickle', 'wb') as f:
pickle.dump(results.history, f)
class LoggingCallback(Callback):
"""Callback that logs message at end of epoch.
"""
def __init__(self, print_fcn=print):
Callback.__init__(self)
self.print_fcn = print_fcn
def on_epoch_end(self, epoch, logs={}):
msg = "Epoch: %i, %s" % (epoch, ", ".join("%s: %f" % (k, v) for k, v in logs.iteritems()))
self.print_fcn(msg)
class LoggingCallback(Callback):
"""Callback that logs message at end of epoch.
"""
def __init__(self, print_fcn=print):
Callback.__init__(self)
self.print_fcn = print_fcn
def on_epoch_end(self, epoch, logs={}):
msg = "{Epoch: %i} %s" % (epoch, ", ".join("%s: %f" % (k, v) for k, v in logs.items()))
self.print_fcn(msg)