Hi,
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())
Link:
- code: https://github.com/Lightning-AI/dl-fundamentals/blob/main/unit05-lightning/exercises/solutions/2_custom-callback/training.py
- documentation of CSVLogger: CSVLogger — PyTorch Lightning 2.0.8 documentation
Thank you!