INNER CODE UNIT · Python
_record_stats
joeddav/devol · devol/devol.py:181
def _record_stats(self, model, genome, loss, accuracy):
with open(self.datafile, 'a') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
row = list(genome) + [loss, accuracy]
writer.writerow(row)
met = loss if self._metric == 'loss' else accuracy
if (self._bssf is -1 or
self._metric_op(met, self._bssf) and
accuracy is not 0):
try:
os.remove('best-model.h5')
except OSError:
pass
self._bssf = met
model.save('best-model.h5')