Strategy#

class Strategy[소스]#

기반 클래스: ABC

Abstract base class for server strategy implementations.

메소드

aggregate_evaluate(server_round, results, ...)

Aggregate evaluation results.

aggregate_fit(server_round, results, failures)

Aggregate training results.

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 the current model parameters.

initialize_parameters(client_manager)

Initialize the (global) model parameters.

abstract 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 results.

매개변수:
  • server_round (int) – The current round of federated learning.

  • results (List[Tuple[ClientProxy, FitRes]]) – Successful updates from the previously selected and configured clients. Each pair of (ClientProxy, FitRes constitutes a successful update from one of the previously selected clients. Not that not all previously selected clients are necessarily included in this list: a client might drop out and not submit a result. For each client that did not submit an update, there should be an Exception in failures.

  • failures (List[Union[Tuple[ClientProxy, EvaluateRes], BaseException]]) – Exceptions that occurred while the server was waiting for client updates.

반환:

aggregation_result – The aggregated evaluation result. Aggregation typically uses some variant of a weighted average.

반환 형식:

Tuple[Optional[float], Dict[str, Scalar]]

abstract 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 training results.

매개변수:
  • server_round (int) – The current round of federated learning.

  • results (List[Tuple[ClientProxy, FitRes]]) – Successful updates from the previously selected and configured clients. Each pair of (ClientProxy, FitRes) constitutes a successful update from one of the previously selected clients. Not that not all previously selected clients are necessarily included in this list: a client might drop out and not submit a result. For each client that did not submit an update, there should be an Exception in failures.

  • failures (List[Union[Tuple[ClientProxy, FitRes], BaseException]]) – Exceptions that occurred while the server was waiting for client updates.

반환:

parameters – If parameters are returned, then the server will treat these as the new global model parameters (i.e., it will replace the previous parameters with the ones returned from this method). If None is returned (e.g., because there were only failures and no viable results) then the server will no update the previous model parameters, the updates received in this round are discarded, and the global model parameters remain the same.

반환 형식:

Tuple[Optional[Parameters], Dict[str, Scalar]]

abstract configure_evaluate(server_round: int, parameters: Parameters, client_manager: ClientManager) List[Tuple[ClientProxy, EvaluateIns]][소스]#

Configure the next round of evaluation.

매개변수:
  • server_round (int) – The current round of federated learning.

  • parameters (Parameters) – 현재(전역) 모델 매개변수입니다.

  • client_manager (ClientManager) – The client manager which holds all currently connected clients.

반환:

evaluate_configuration – A list of tuples. Each tuple in the list identifies a ClientProxy and the EvaluateIns for this particular ClientProxy. If a particular ClientProxy is not included in this list, it means that this ClientProxy will not participate in the next round of federated evaluation.

반환 형식:

List[Tuple[ClientProxy, EvaluateIns]]

abstract configure_fit(server_round: int, parameters: Parameters, client_manager: ClientManager) List[Tuple[ClientProxy, FitIns]][소스]#

Configure the next round of training.

매개변수:
  • server_round (int) – The current round of federated learning.

  • parameters (Parameters) – 현재(전역) 모델 매개변수입니다.

  • client_manager (ClientManager) – The client manager which holds all currently connected clients.

반환:

fit_configuration – A list of tuples. Each tuple in the list identifies a ClientProxy and the FitIns for this particular ClientProxy. If a particular ClientProxy is not included in this list, it means that this ClientProxy will not participate in the next round of federated learning.

반환 형식:

List[Tuple[ClientProxy, FitIns]]

abstract evaluate(server_round: int, parameters: Parameters) Tuple[float, Dict[str, bool | bytes | float | int | str]] | None[소스]#

Evaluate the current model parameters.

This function can be used to perform centralized (i.e., server-side) evaluation of model parameters.

매개변수:
  • server_round (int) – The current round of federated learning.

  • parameters (Parameters) – 현재(전역) 모델 매개변수입니다.

반환:

evaluation_result – The evaluation result, usually a Tuple containing loss and a dictionary containing task-specific metrics (e.g., accuracy).

반환 형식:

Optional[Tuple[float, Dict[str, Scalar]]]

abstract initialize_parameters(client_manager: ClientManager) Parameters | None[소스]#

Initialize the (global) model parameters.

매개변수:

client_manager (ClientManager) – The client manager which holds all currently connected clients.

반환:

parameters – If parameters are returned, then the server will treat these as the initial global model parameters.

반환 형식:

Optional[Parameters]