TsingZ0 / PFLlib

37 traditional FL (tFL) or personalized FL (pFL) algorithms, 3 scenarios, and 20 datasets.
GNU General Public License v2.0
1.36k stars 285 forks source link

Use the trained model after FL #114

Closed ajulyav closed 1 year ago

ajulyav commented 1 year ago

Hello,

I try to use the final global model to test it later. I have .pt model saved in the folder. When I try to torch.load it

it shows me an error:

pretrained_weights = torch.load('./experiment1/FedAvg_server.pt')
model_conv = models.resnet18(pretrained=False)
model_conv.load_state_dict(pretrained_weights)
   1163         pass
   1164 mod_name = load_module_mapping.get(mod_name, mod_name)
-> 1165 return super().find_class(mod_name, name)

ModuleNotFoundError: No module named 'flcore'

How can I use my global model?

ajulyav commented 1 year ago

Those who look how to solve this. You have to make sure the source file structure is equal in your working environment compared to the environment the model was saved from.

So, store your test code in the folder ''system', it should work now.