NumPyClient¶
- class NumPyClient[source]¶
Bases:
ABC
Abstract base class for Flower clients using NumPy.
Methods
evaluate
(parameters, config)Evaluate the provided parameters using the locally held dataset.
fit
(parameters, config)Train the provided parameters using the locally held dataset.
get_parameters
(config)Return the current local model parameters.
get_properties
(config)Return a client's set of properties.
Convert to object to Client type and return it.
- evaluate(parameters: list[ndarray[Any, dtype[Any]]], config: dict[str, bool | bytes | float | int | str]) tuple[float, int, dict[str, bool | bytes | float | int | str]] [source]¶
Evaluate the provided parameters using the locally held dataset.
- Parameters:
parameters (NDArrays) – The current (global) model parameters.
config (Dict[str, Scalar]) – Configuration parameters which allow the server to influence evaluation on the client. It can be used to communicate arbitrary values from the server to the client, for example, to influence the number of examples used for evaluation.
- Returns:
loss (float) – The evaluation loss of the model on the local dataset.
num_examples (int) – The number of examples used for evaluation.
metrics (Dict[str, Scalar]) – A dictionary mapping arbitrary string keys to values of type bool, bytes, float, int, or str. It can be used to communicate arbitrary values back to the server.
Warning
The previous return type format (int, float, float) and the extended format (int, float, float, Dict[str, Scalar]) have been deprecated and removed since Flower 0.19.
- fit(parameters: list[ndarray[Any, dtype[Any]]], config: dict[str, bool | bytes | float | int | str]) tuple[list[ndarray[Any, dtype[Any]]], int, dict[str, bool | bytes | float | int | str]] [source]¶
Train the provided parameters using the locally held dataset.
- Parameters:
parameters (NDArrays) – The current (global) model parameters.
config (Dict[str, Scalar]) – Configuration parameters which allow the server to influence training on the client. It can be used to communicate arbitrary values from the server to the client, for example, to set the number of (local) training epochs.
- Returns:
parameters (NDArrays) – The locally updated model parameters.
num_examples (int) – The number of examples used for training.
metrics (Dict[str, Scalar]) – A dictionary mapping arbitrary string keys to values of type bool, bytes, float, int, or str. It can be used to communicate arbitrary values back to the server.
- get_parameters(config: dict[str, bool | bytes | float | int | str]) list[ndarray[Any, dtype[Any]]] [source]¶
Return the current local model parameters.
- Parameters:
config (Config) – Configuration parameters requested by the server. This can be used to tell the client which parameters are needed along with some Scalar attributes.
- Returns:
parameters – The local model parameters as a list of NumPy ndarrays.
- Return type:
NDArrays
- get_properties(config: dict[str, bool | bytes | float | int | str]) dict[str, bool | bytes | float | int | str] [source]¶
Return a client’s set of properties.
- Parameters:
config (Config) – Configuration parameters requested by the server. This can be used to tell the client which properties are needed along with some Scalar attributes.
- Returns:
properties – A dictionary mapping arbitrary string keys to values of type bool, bytes, float, int, or str. It can be used to communicate arbitrary property values back to the server.
- Return type:
Dict[str, Scalar]