Hi,
I’m trying to use my own callback. It’s being called, but its output seems not to be recorded or writed to history.csv
from fastai.callbacks import LearnerCallback
class MyCallback(LearnerCallback):
def __init__(self, learn:Learner):
super().__init__(learn)
def on_train_begin(self, **kwargs):
self.learn.recorder.add_metric_names(['fold', 'cycle'])
def on_epoch_end(self, last_metrics, **kwargs):
f=globals().get('fold_id', -1)
c=-1 if not 'checkpoints_saver' in globals() else get_int_parameter_from_string('cyc',checkpoints_saver.name)
print("last_metrics, [f,c]",last_metrics, [f,c])
return add_metrics(last_metrics, [f,c])
…
learn = cnn_learner(…)
callbacks=[SaveModelCallback(learn, every=‘epoch’, monitor=‘accuracy’, name=checkpoints_save_name),
PeakMemMetric(learn),
MyCallback(learn),
CSVLogger(learn, filename=CSV_LOGGER_FILENAME.replace(".csv",""),append=True)]
learn.fit_one_cycle(…, callbacks=callbacks)
What am I doing wrong?
TIA