You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since I don't know your use case, I can only give a simple example below.
Assume you have saved a server object, for example, using the code here. As you can see, I only used the torch.save.
Could you please try the following code snippet? Since I did not have the access to the server anymore, I cannot test it on my end.
fromsrc.utilsimportload_from_pkl, save_to_pklimportpickleclassCPU_Unpickler(pickle.Unpickler):
deffind_class(self, module, name):
ifmodule=='torch.storage'andname=='_load_from_bytes':
returnlambdab: torch.load(io.BytesIO(b), map_location='cpu')
else: returnsuper().find_class(module, name)
defload_from_pkl(path):
withopen(path, 'rb') asfile:
data=CPU_Unpickler(file).load()
returndata# assume that you have server_object=load_from_pkl("your_pkl_file")
# the global model server_object.server_model_state_dict# once you have the model saved as the state_dict, you can load the torch model using `torch.load`.
To get the client side models, I think you may need to starting with the saved final the global model, and fine-tuning it with the local data for a few steps. I didn't think I saved the local models explictly.
Could you please offer the code for reloading trained models (saved as .pkl files)?
The text was updated successfully, but these errors were encountered: