Source code for proton_decay_study.callbacks.default

"""
    Defines the default callbacks for usage in the mod:`proton_decay_study`
"""
import json
from keras.callbacks import Callback


[docs]class HistoryRecord(Callback): """ This is a stub in place for working on recording the training history """
[docs] def on_train_begin(self, logs={}): self.losses = []
self.accuracy = []
[docs] def on_batch_end(self, batch, logs={}): self.losses.append(logs.get('loss'))
self.accuracy.append(logs.get('acc'))
[docs] def write(self, filename): with open(filename, 'w') as output: output.write(json.dumps({'loss': self.losses,
'accuracy': self.accuracy}))