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

can you provide transfer learning code? #5

Closed
ai-motive opened this issue Jun 8, 2021 · 1 comment
Closed

can you provide transfer learning code? #5

ai-motive opened this issue Jun 8, 2021 · 1 comment

Comments

@ai-motive
Copy link

Hi~ @Green-Wood

I wanna apply trasnfer learning using pretrained model.

but, LightningCLI() is wrapped and difficult to customize.

Thanks & best regards.

@Green-Wood
Copy link
Owner

If you want to finetune our model in the other dataset, I suggest you refer to PyTorch-Lightning transfer learning documentation and PyTorch official tutorial.

Basically, you need to:

  1. load pretrained model.
  2. freeze some layers.
  3. train it on the other dataset.

Like the following code:

from bttr.datamodule import CROHMEDatamodule
from bttr import LitBTTR
from pytorch_lightning import Trainer

# model
model = LitBTTR.load_from_checkpoint(ckp_path)

# data
dm = SomeOtherDataset()

# train
trainer = Trainer()
trainer.fit(model, datamodule=dm)

# test using the best model!
trainer.test(datamodule=dm)

However, we won't give out these codes in this repo directly.
Hope that can help you.

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

No branches or pull requests

2 participants