DifferentialPrivacyServerSideFixedClipping#
- class DifferentialPrivacyServerSideFixedClipping(strategy: Strategy, noise_multiplier: float, clipping_norm: float, num_sampled_clients: int)[源代码]#
基类:
Strategy
Strategy wrapper for central DP with server-side fixed clipping.
- 参数:
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. A value of 1.0 or higher is recommended for strong privacy.
clipping_norm (float) -- The value of the clipping norm.
num_sampled_clients (int) -- The number of clients that are sampled on each round.
示例
Create a strategy:
>>> strategy = fl.server.strategy.FedAvg( ... )
Wrap the strategy with the DifferentialPrivacyServerSideFixedClipping wrapper
>>> dp_strategy = DifferentialPrivacyServerSideFixedClipping( >>> strategy, cfg.noise_multiplier, cfg.clipping_norm, cfg.num_sampled_clients >>> )
Methods
aggregate_evaluate
(server_round, results, ...)使用给定的策略汇总评估损失。
aggregate_fit
(server_round, results, failures)Compute the updates, clip, and pass them for aggregation.
configure_evaluate
(server_round, parameters, ...)配置下一轮评估。
configure_fit
(server_round, parameters, ...)配置下一轮训练。
evaluate
(server_round, parameters)使用策略中的评估函数评估模型参数。
initialize_parameters
(client_manager)使用给定的策略初始化全局模型参数。
- aggregate_evaluate(server_round: int, results: List[Tuple[ClientProxy, EvaluateRes]], failures: List[Tuple[ClientProxy, EvaluateRes] | BaseException]) Tuple[float | None, Dict[str, bool | bytes | float | int | str]] [源代码]#
使用给定的策略汇总评估损失。
- aggregate_fit(server_round: int, results: List[Tuple[ClientProxy, FitRes]], failures: List[Tuple[ClientProxy, FitRes] | BaseException]) Tuple[Parameters | None, Dict[str, bool | bytes | float | int | str]] [源代码]#
Compute the updates, clip, and pass them for aggregation.
Afterward, add noise to the aggregated parameters.
- configure_evaluate(server_round: int, parameters: Parameters, client_manager: ClientManager) List[Tuple[ClientProxy, EvaluateIns]] [源代码]#
配置下一轮评估。
- configure_fit(server_round: int, parameters: Parameters, client_manager: ClientManager) List[Tuple[ClientProxy, FitIns]] [源代码]#
配置下一轮训练。
- evaluate(server_round: int, parameters: Parameters) Tuple[float, Dict[str, bool | bytes | float | int | str]] | None [源代码]#
使用策略中的评估函数评估模型参数。
- initialize_parameters(client_manager: ClientManager) Parameters | None [源代码]#
使用给定的策略初始化全局模型参数。