How to save custom metrics in metrics.csv from custom callback?


In the exercises we implemented train_val_diff metric from the custom callback, what if we want to save this metrics in the metrics.csv file from CSVLogger?

class CustomCallback(Callback): def on_validation_epoch_end(self, trainer, lightning_module): print(lightning_module.train_acc.compute(), lightning_module.val_acc.compute()) diff = lightning_module.train_acc.compute() - lightning_module.val_acc.compute() train_val_diff.append(diff.item())


Thank you!