Skip to content
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 pretrained model validation before fine-tuning #744

Closed
hbredin opened this issue Sep 9, 2021 · 7 comments
Closed

Log pretrained model validation before fine-tuning #744

hbredin opened this issue Sep 9, 2021 · 7 comments

Comments

@hbredin
Copy link
Member

hbredin commented Sep 9, 2021

To make sure fine-tuning actually improves performance, it would be nice to run (and log) a full validation loop before training.

Related Lightning-AI/pytorch-lightning#1715

@hbredin
Copy link
Member Author

hbredin commented Oct 12, 2021

I haven't tried this yet but the linked issue above contains a "solution" that advises to run trainer.validate(model) before calling trainer.fit(model). Did you try this? Does this work?

@dapello
Copy link

dapello commented Nov 15, 2021

yes, it seems like in v 1.5.1, calling trainer.validate(model) before trainer.fit(model) adds the initial validation score to the logs!

@stale
Copy link

stale bot commented Jan 14, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 14, 2022
@stale stale bot closed this as completed Jan 21, 2022
@hbredin hbredin reopened this Jan 21, 2022
@stale stale bot removed the wontfix label Jan 21, 2022
@hbredin
Copy link
Member Author

hbredin commented Feb 17, 2022

Not perfect, but it does the trick...

validate

cc @FrenchKrab @juanmc2005

@odedbd
Copy link

odedbd commented Aug 1, 2022

When running trainer.validate(model) before trainer.fit(model), the val dataloader is initialized twice (workers are initialized twice). In my use case, workers initialization is a costly process, so it would be beneficial if the val dataloader workers created when running trainer.validate would be reused when running trainer.fit.

Is there a way to set this up while using a DataModule as the datasource for trainer.validate and trainer.fit?

@juanmc2005
Copy link
Collaborator

@odedbd have you tried setting persistent_workers=True when instantiating the validation DataLoader? I think this could solve your problem.

@odedbd
Copy link

odedbd commented Aug 2, 2022

@juanmc2005 Thank you for the suggestion, I am already using persistent_workers=True and it doesn't seem to effect the creation of workers when using DataModule and running trainer.validate before trainer.fit.

I just realized I posted my comment on an issue of the pyannote-audio repository rather then that related Pytorch Lightning issue, where it probably belongs. Sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants