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

I changed the loss value to nan after using the DPFedAvgAdaptive class #2342

Closed
helin0815 opened this issue Sep 12, 2023 · 10 comments
Closed

Comments

@helin0815
Copy link
Contributor

What is your question?

My Reproduction Code:

strategy = fl.server.strategy.FedAvg(
fraction_fit=0.2,
fraction_evaluate=0.2,
min_fit_clients=2,
min_evaluate_clients=2,
min_available_clients=5,
evaluate_fn=get_evaluate_fn(model, args.toy),
on_fit_config_fn=fit_config,
on_evaluate_config_fn=evaluate_config,
initial_parameters=fl.common.ndarrays_to_parameters(model_parameters),
)
strategy_adp = DPFedAvgAdaptive(
strategy=strategy,
num_sampled_clients=10,
init_clip_norm=0.1,
noise_multiplier=1.1,
server_side_noising=True,
clip_norm_lr=0.2,
clip_norm_target_quantile=0.5,
clip_count_stddev=None,
)
strategy_dp_fixed = DPFedAvgFixed(
strategy=strategy,
num_sampled_clients=2,
clip_norm=0.1
)
fl.server.start_server(
server_address="0.0.0.0:8080",
config=fl.server.ServerConfig(num_rounds=4),
strategy=strategy_adp,
)

And after four rounds of training, the result was like this:

INFO flwr 2023-09-11 23:34:26,374 | app.py:221 | app_fit: losses_centralized [(0, 722.7143316268921), (1, nan), (2, nan), (3, nan), (4, nan)]
INFO flwr 2023-09-11 23:34:26,374 | app.py:222 | app_fit: metrics_centralized {'accuracy': [(0, 0.1314), (1, 0.0986), (2, 0.0986), (3, 0.0986), (4, 0.0986)]}
Why did my loss value change to nan?

@helin0815
Copy link
Contributor Author

I am addressing this issue: #2782. Due to the fact that efficientnet is particularly sensitive to noise, it is recommended to use alexnet, imagenet-based models, or other alternatives for implementing differential privacy.

@CHENxx23
Copy link

I have the same problem, is there a solution?

@helin0815
Copy link
Contributor Author

I have the same problem, is there a solution?

你别用他自带的那个模型,你换个模型就行了,比如alexnet或者resnet模型就没这个毛病

@CHENxx23
Copy link

The model I chose is my own model that is there about time prediction and didn't use the one he comes with and still this problem occurs.

@helin0815
Copy link
Contributor Author

The model I chose is my own model that is there about time prediction and didn't use the one he comes with and still this problem occurs.

some models do have this problem. You can try a different Alexnet model first. If Alexnet does not have this problem but your model has it, then you need to consider processing your model

@CHENxx23
Copy link

I solved this problem, I see your results, the accuracy is not updated for each round, what is this problem, I feel that his set_parameters function and get_parameters are not working, the test function's model parameters are not aggregated and updated

@helin0815
Copy link
Contributor Author

I solved this problem, I see your results, the accuracy is not updated for each round, what is this problem, I feel that his set_parameters function and get_parameters are not working, the test function's model parameters are not aggregated and updated

I have also solved this problem. My solution is to replace the model. How did you solve this problem?

@CHENxx23
Copy link

Can we communicate by e-mail? This message communication is not too timely.Here's my email address: [email protected]

@WilliamLindskog
Copy link
Contributor

Hi @helin0815

Thanks for raising this. Are you still experiencing this issue?

@WilliamLindskog
Copy link
Contributor

Closing this issue as it seems to have been resolved by changing models.

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

3 participants