KarhouTam / FL-bench

Benchmark of federated learning. Dedicated to the community. 🤗
GNU General Public License v3.0
503 stars 82 forks source link

Pretrained model loading #26

Closed xuhang2019 closed 1 year ago

xuhang2019 commented 1 year ago

Many thanks for the contribution to FL community. Really benefit a lot.

When I wanted to load the pretrained model, I didn't find a universal/easy way to do it, (i.e., in args).

After checking the code, I believe I should change the first parameter in trainable_params change to my desired checkpoints.

        self.model = use_model.to(self.device)

        # FIXME: using pre-trained models
        init_trainable_params, self.trainable_params_name = trainable_params(
            self.model, detach=True, requires_name=True
        )

Am I corrected? Thank you very much for your reply!

KarhouTam commented 1 year ago

Thanks for your attention first, @xuhang2019 .

For your question, yeah, you code in the right place 😄. NOTE: If you wanna load your own pretrained parameters, you need to confirm the parameters' shape is identical to the model's by yourself.

Seems I developed the saving model parameters feature but forgot the loading custom model parameters part 😂.

That feature will be on my list.

xuhang2019 commented 1 year ago

Many thanks. Look forward to it! Brilliant.