Logging a running max val_acc_epoch in TensorBoard hparams tab #15759
Unanswered
daniel-a-diaz
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently I am using
TensorBoardLogger
withdefault_hp_metric=False
, and logging hyperparameters and metrics to the hparams tab before I calltrainer.fit()
like thisAnd then in
LightningModule
, withtorchmetrics.Accuracy
I keep a running log of val_accuracy like thisWhat I want to do is keep a running log of the max epoch val_accuracy. It seemed like I could do this with
reduce_fx='max'
, except it doesn't apply when usingtorchmetrics.Metric
. I have tried experimenting withtorchmetrics.MinMaxMetric
, but I couldn't get it to work. Is there anything likeModelCheckpoint.best_model_score
you can call within the validation_step? I have been simply doinglog.hyperparams
a second time with the best_model_score after runningtrainer.fit()
, which works fine usingDDPStrategy
and Lightning'sEarlyStopping
. But when I was running Optuna studies in parallel with their pruner using thePyTorchLightningPruningCallback
integration, I was having issues with updating the val_accuracy to the best score correctly after training. Or actually even running any code at all aftertrainer.fit()
. It looks like pruned trials return fromtrainer.fit()
so that any code afterwards doesn't run.So my question is what would be the most elegant lightning solution for getting this to work. It would be nice to easily sort the hparams tab based on the val_accuracy of the
save_top_k=1
checkpoint.Also I am using pytorch-lightning=1.5.10 in order to run Optuna in parallel and use their
PyTorchLightningPruningCallback
integration. Thanks.Beta Was this translation helpful? Give feedback.
All reactions