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 the run context from this client.
get_parameters
(config)Return the current local model parameters.
get_properties
(config)Return a client's set of properties.
set_context
(context)Apply a run context to this client.
Convert to object to Client type and return it.
Attributes
Getter for Context client attribute.
- 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.
- Paramètres:
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.
- Renvoie:
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.
Avertissement
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.
- Paramètres:
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.
- Renvoie:
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.
- Paramètres:
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.
- Renvoie:
parameters – The local model parameters as a list of NumPy ndarrays.
- Type renvoyé:
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.
- Paramètres:
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.
- Renvoie:
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.
- Type renvoyé:
Dict[str, Scalar]