-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log validation metrics before training #3625
Comments
Hi! thanks for your contribution!, great first issue! |
It's because model checkpointing occur with |
I faced this issue too. It seems to be an important functionality in transfer learning or fine-tuning, trainer = Trainer(
...,
eval_before_training=True
) How do you think about it? @williamFalcon and .@othercontributors |
I agree that it would be nice to have a flag like class ValidationOnStartCallback(pl.callbacks.Callback):
def on_train_start(self, trainer, pl_module):
trainer.checkpoint_callback.on_train_start(trainer, pl_module)
return trainer.run_evaluation(test_mode=False) |
This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions, Pytorch Lightning Team! |
Agree with @S-aiueo32 that this would be a neat solution for logging metrics before training (very useful in transfer learning). Or is there since then another neat solution to do this? |
At least as of 1.4.4 (but maybe before) trainer = pl.Trainer(...., logger=[tb_logger, csv_logger], callbacks=[chk]) Does what you want, assuming the model weights are initialized to what you need. |
Hey, Thanks for all the helpful comments here, unfortunately they do not work for me. I'm using LightningCLI, so I can't run:
Myself as suggested above. I've been trying to get a callback to work as suggested by @hantoine , but
but I'm running in various problems. In the example given above I'm getting:
as running trainer.validate changed the state of my trainer. When hacking into the state in my callback:
I'm getting the following error:
Which seems to be caused because self.model on line 332 is a lightningmodule, while when running it without the callback, the class is: Did anyone get the callback approach to work? I agree with the general sentiment here that this is very useful functionality when finetuning models (a lot of the gains are often made in the first epoch of training, so having a before and after in validation performance is important) and I'm surprised how hard this turns out to be. |
❓ Questions and Help
Is there an easy way to run a full evaluation on the the validation set before starting training. I would like this as a kind of benchmark to see where I'm starting from and if the network learns anything at all.
While #1715 allows running the sanity check on the complete validation set, this does not log any metrics.
I tried the code as recommended:
Originally posted by @dvirginz in #1715 (comment)
but this gives me the following error:
Is there no simple way to run and log the validation set before training?
The text was updated successfully, but these errors were encountered: