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

fix(framework) Add default loss value for QFedAvg #4641

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

WilliamLindskog
Copy link
Contributor

@WilliamLindskog WilliamLindskog commented Dec 5, 2024

Issue

When running qfedavg strategy and eval_result is None, it throws following error:

[np.float_power(loss + 1e-10, self.q_param) * grad for grad in grads]
NameError: free variable 'loss' referenced before assignment in enclosing scope

Description

Basically, there is no default value for loss before it is referenced in above calculation.

Related issues/PRs

#804

Proposal

Setting loss to 0.0 as default value fixes this.

Explanation

A neutral loss default value, will not affect the following calculations.

Checklist

  • Implement proposed change
  • Write tests
  • Update documentation
  • Make CI checks pass
  • Ping maintainers on Slack (channel #contributions)

Any other comments?

Comment on lines 197 to 198
log(WARNING, "Evaluate method returned None, using default loss value")
loss = 0.0 # Default value for loss
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WilliamLindskog where did you see loss=0.0 being the default?

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

Successfully merging this pull request may close these issues.

2 participants