FedAvgAndroid#
- class FedAvgAndroid(*, fraction_fit: float = 1.0, fraction_evaluate: float = 1.0, min_fit_clients: int = 2, min_evaluate_clients: int = 2, min_available_clients: int = 2, 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, accept_failures: bool = True, initial_parameters: Parameters | None = None)[소스]#
기반 클래스:
Strategy
Federated Averaging strategy.
Implementation based on https://arxiv.org/abs/1602.05629
- 매개변수:
fraction_fit (Optional[float]) – Fraction of clients used during training. Defaults to 1.0.
fraction_evaluate (Optional[float]) – Fraction of clients used during validation. Defaults to 1.0.
min_fit_clients (Optional[int]) – Minimum number of clients used during training. Defaults to 2.
min_evaluate_clients (Optional[int]) – Minimum number of clients used during validation. Defaults to 2.
min_available_clients (Optional[int]) – Minimum number of total clients in the system. Defaults to 2.
evaluate_fn (Optional[Callable[[int, NDArrays, Dict[str, Scalar]], Optional[Tuple[float, Dict[str, Scalar]]]]]) – Optional function used for validation. Defaults to None.
on_fit_config_fn (Optional[Callable[[int], Dict[str, Scalar]]]) – Function used to configure training. Defaults to None.
on_evaluate_config_fn (Optional[Callable[[int], Dict[str, Scalar]]]) – Function used to configure validation. Defaults to None.
accept_failures (Optional[bool]) – Whether or not accept rounds containing failures. Defaults to True.
initial_parameters (Optional[Parameters]) – Initial global model parameters.
메소드
aggregate_evaluate
(server_round, results, ...)Aggregate evaluation losses using weighted average.
aggregate_fit
(server_round, results, failures)Aggregate fit results using weighted average.
bytes_to_ndarray
(tensor)Deserialize NumPy array from bytes.
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.
initialize_parameters
(client_manager)Initialize global model parameters.
ndarray_to_bytes
(ndarray)Serialize NumPy array to bytes.
ndarrays_to_parameters
(ndarrays)NumPy 배열을 매개변수 객체로 변환합니다.
num_evaluation_clients
(num_available_clients)Use a fraction of available clients for evaluation.
num_fit_clients
(num_available_clients)Return the sample size and the required number of available clients.
parameters_to_ndarrays
(parameters)Convert parameters object to NumPy weights.
- 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 evaluation losses using weighted average.
- 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]] [소스]#
Aggregate fit results using weighted average.
- configure_evaluate(server_round: int, parameters: Parameters, client_manager: ClientManager) List[Tuple[ClientProxy, EvaluateIns]] [소스]#
Configure the next round of evaluation.
- configure_fit(server_round: int, parameters: Parameters, client_manager: ClientManager) List[Tuple[ClientProxy, FitIns]] [소스]#
Configure the next round of training.
- evaluate(server_round: int, parameters: Parameters) Tuple[float, Dict[str, bool | bytes | float | int | str]] | None [소스]#
Evaluate model parameters using an evaluation function.
- initialize_parameters(client_manager: ClientManager) Parameters | None [소스]#
Initialize global model parameters.
- ndarrays_to_parameters(ndarrays: List[ndarray[Any, dtype[Any]]]) Parameters [소스]#
NumPy 배열을 매개변수 객체로 변환합니다.
- num_evaluation_clients(num_available_clients: int) Tuple[int, int] [소스]#
Use a fraction of available clients for evaluation.
- num_fit_clients(num_available_clients: int) Tuple[int, int] [소스]#
Return the sample size and the required number of available clients.
- parameters_to_ndarrays(parameters: Parameters) List[ndarray[Any, dtype[Any]]] [소스]#
Convert parameters object to NumPy weights.