FaultTolerantFedAvg¶
- class FaultTolerantFedAvg(*, fraction_fit: float = 1.0, fraction_evaluate: float = 1.0, min_fit_clients: int = 1, min_evaluate_clients: int = 1, min_available_clients: int = 1, evaluate_fn: Callable[[int, list[ndarray[Any, dtype[Any]]], dict[str, bool | bytes | float | int | str]], tuple[float, dict[str, bool | bytes | float | int | str]] | None] | None = None, on_fit_config_fn: Callable[[int], dict[str, bool | bytes | float | int | str]] | None = None, on_evaluate_config_fn: Callable[[int], dict[str, bool | bytes | float | int | str]] | None = None, min_completion_rate_fit: float = 0.5, min_completion_rate_evaluate: float = 0.5, initial_parameters: Parameters | None = None, fit_metrics_aggregation_fn: Callable[[list[tuple[int, dict[str, bool | bytes | float | int | str]]]], dict[str, bool | bytes | float | int | str]] | None = None, evaluate_metrics_aggregation_fn: Callable[[list[tuple[int, dict[str, bool | bytes | float | int | str]]]], dict[str, bool | bytes | float | int | str]] | None = None)[source]¶
Bases:
FedAvg
可配置的容错 FedAvg 策略实施。
Methods
aggregate_evaluate
(server_round, results, ...)采用加权平均法计算评估损失总额。
aggregate_fit
(server_round, results, failures)使用加权平均法汇总拟合结果。
configure_evaluate
(server_round, parameters, ...)配置下一轮评估。
configure_fit
(server_round, parameters, ...)配置下一轮训练。
evaluate
(server_round, parameters)使用评估函数评估模型参数。
initialize_parameters
(client_manager)初始化全局模型参数。
num_evaluation_clients
(num_available_clients)使用部分可用客户进行评估。
num_fit_clients
(num_available_clients)返回样本大小和所需的可用客户数量。
- 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]] [source]¶
采用加权平均法计算评估损失总额。
- 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]] [source]¶
使用加权平均法汇总拟合结果。
- 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 ¶
初始化全局模型参数。
- num_evaluation_clients(num_available_clients: int) tuple[int, int] ¶
使用部分可用客户进行评估。
- num_fit_clients(num_available_clients: int) tuple[int, int] ¶
返回样本大小和所需的可用客户数量。