How to load a pretrained model and train again?

I want to train a model on a different dataset then save those weights and load them to another dataset and finetune them for the other dataset. How can I do this?
(Both the datasets are similar).
Thanks.

This action is called resuming, you can refer how-to-resume-training

2 Likes

Thanks for your reply. I don’t actually want to resume training, I want to load those weights and retrain so that those weights could the model a head-start.

Do you mean

  1. train the model on datasetA
  2. save the trained weights to modelA
  3. fine-tune the trained modelA on datasetB

if in this way, what you are looking for is fine-tune?

1 Like

If I am using a pretrained model from timm do I have to set requires_grad to False?

No, you can refer, set-model-parameters-requires-grad-attribute

basically,
requires_grad=True , means you want to train or fine-tune a model
requires_grad=False, means you want to use the model to test or infer

1 Like

Thanks a lot man, I’ll try it.