DifferentialPrivacyClientSideAdaptiveClipping#
- class DifferentialPrivacyClientSideAdaptiveClipping(strategy: Strategy, noise_multiplier: float, num_sampled_clients: int, initial_clipping_norm: float = 0.1, target_clipped_quantile: float = 0.5, clip_norm_lr: float = 0.2, clipped_count_stddev: float | None = None)[소스]#
기반 클래스:
Strategy
Strategy wrapper for central DP with client-side adaptive clipping.
Use adaptiveclipping_mod modifier at the client side.
In comparison to DifferentialPrivacyServerSideAdaptiveClipping, which performs clipping on the server-side, DifferentialPrivacyClientSideAdaptiveClipping expects clipping to happen on the client-side, usually by using the built-in adaptiveclipping_mod.
- 매개변수:
strategy (Strategy) – The strategy to which DP functionalities will be added by this wrapper.
noise_multiplier (float) – The noise multiplier for the Gaussian mechanism for model updates.
num_sampled_clients (int) – The number of clients that are sampled on each round.
initial_clipping_norm (float) – The initial value of clipping norm. Defaults to 0.1. Andrew et al. recommends to set to 0.1.
target_clipped_quantile (float) – The desired quantile of updates which should be clipped. Defaults to 0.5.
clip_norm_lr (float) – The learning rate for the clipping norm adaptation. Defaults to 0.2. Andrew et al. recommends to set to 0.2.
clipped_count_stddev (float) – The stddev of the noise added to the count of updates currently below the estimate. Andrew et al. recommends to set to expected_num_records/20
예제
Create a strategy:
>>> strategy = fl.server.strategy.FedAvg(...)
Wrap the strategy with the DifferentialPrivacyClientSideAdaptiveClipping wrapper:
>>> dp_strategy = DifferentialPrivacyClientSideAdaptiveClipping( >>> strategy, cfg.noise_multiplier, cfg.num_sampled_clients >>> )
On the client, add the adaptiveclipping_mod to the client-side mods:
>>> app = fl.client.ClientApp( >>> client_fn=client_fn, mods=[adaptiveclipping_mod] >>> )
메소드
aggregate_evaluate
(server_round, results, ...)Aggregate evaluation losses using the given strategy.
aggregate_fit
(server_round, results, failures)Aggregate training results and update clip norms.
configure_evaluate
(server_round, parameters, ...)Configure the next round of evaluation.
configure_fit
(server_round, parameters, ...)Configure the next round of training.
evaluate
(server_round, parameters)Evaluate model parameters using an evaluation function from the strategy.
initialize_parameters
(client_manager)Initialize global model parameters using given strategy.
- aggregate_evaluate(server_round: int, results: list[tuple[flwr.server.client_proxy.ClientProxy, flwr.common.typing.EvaluateRes]], failures: list[Union[tuple[flwr.server.client_proxy.ClientProxy, flwr.common.typing.EvaluateRes], BaseException]]) tuple[Optional[float], dict[str, Union[bool, bytes, float, int, str]]] [소스]#
Aggregate evaluation losses using the given strategy.
- aggregate_fit(server_round: int, results: list[tuple[flwr.server.client_proxy.ClientProxy, flwr.common.typing.FitRes]], failures: list[Union[tuple[flwr.server.client_proxy.ClientProxy, flwr.common.typing.FitRes], BaseException]]) tuple[Optional[flwr.common.typing.Parameters], dict[str, Union[bool, bytes, float, int, str]]] [소스]#
Aggregate training results and update clip norms.
- configure_evaluate(server_round: int, parameters: Parameters, client_manager: ClientManager) list[tuple[flwr.server.client_proxy.ClientProxy, flwr.common.typing.EvaluateIns]] [소스]#
Configure the next round of evaluation.
- configure_fit(server_round: int, parameters: Parameters, client_manager: ClientManager) list[tuple[flwr.server.client_proxy.ClientProxy, flwr.common.typing.FitIns]] [소스]#
Configure the next round of training.
- evaluate(server_round: int, parameters: Parameters) tuple[float, dict[str, Union[bool, bytes, float, int, str]]] | None [소스]#
Evaluate model parameters using an evaluation function from the strategy.
- initialize_parameters(client_manager: ClientManager) Parameters | None [소스]#
Initialize global model parameters using given strategy.