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

Issue in _calculate_model_delta() in federatedscope/core/workers /client.py #787

Open
Pengxin-Guo opened this issue Nov 28, 2024 · 0 comments

Comments

@Pengxin-Guo
Copy link

The _calculate_model_delta() may need to be modified to the code below to satisfy running pFL, since the updated_model is a subset of the init_model:

def _calculate_model_delta(self, init_model, updated_model):
    if not isinstance(init_model, list):
        init_model = [init_model]
        updated_model = [updated_model]

    model_deltas = list()
    for model_index in range(len(init_model)):
        # model_delta = copy.deepcopy(init_model[model_index])
        # for key in init_model[model_index].keys():
        #     model_delta[key] = updated_model[model_index][
        #         key] - init_model[model_index][key]
        
        # added by me, for pFL
        model_delta = copy.deepcopy(updated_model[model_index])
        for key in updated_model[model_index].keys():
            model_delta[key] = updated_model[model_index][
                key] - init_model[model_index][key]
        model_deltas.append(model_delta)

    if len(model_deltas) > 1:
        return model_deltas
    else:
        return model_deltas[0]
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

1 participant