flox.logic.base_client.FloxClientLogic

class FloxClientLogic[source]

Bases: object

Abstract base class for FLoX Clients

Methods

on_data_retrieve

Retrieves data for training the model.

on_model_fit

Fit the provided global model using a local dataset

on_model_receive

Parses & decrypts the received data from a controller

on_model_send

Final data processing before sending the results back, such as encryption.

run_round

Combines the rest of the functions to run a single Federated Learning round

on_data_retrieve(config)[source]

Retrieves data for training the model.

Return type:

XYData

Parameters

config: ConfigFile

a dictionary with values necessary to retrieve the data, such as the data source and preprocessing parameters

Returns

XYData

data for evaluating the model. This can take different forms depending on the ML framework you use. For Tensorflow, it would look as x_test and y_test, while for PyTorch, it would look as a single DataLoader instance.

on_model_fit()[source]

Fit the provided global model using a local dataset

Return type:

List[ndarray[Any, dtype[Any]]]

Parameters

Parameters for fitting the model. This might take different forms depending on the ML framework. For Tensorflow, it might look like this:

model: keras.Sequential ModelTrainer: Class config: ConfigFile x_train: NDArrays y_train: Union[NDArray, NDArrays]

Returns

NDArrays

new model weights as Numpy arrays

on_model_receive()[source]

Parses & decrypts the received data from a controller

Return type:

None

on_model_send()[source]

Final data processing before sending the results back, such as encryption.

Return type:

dict

Returns

results: dict

FL results formatted as a dictionary. For example: results = {

“model_weights”: model_weights, “samples_count”: samples_count, “bias_weights”: fractions,

}

run_round(model_trainer, config)[source]

Combines the rest of the functions to run a single Federated Learning round

Return type:

dict

Parameters

model_trainer

instance of a class based on BaseModelTrainer that implements .fit(), .evaluate(), .get_weights(), and .set_weights()

config: dict

a dictionary with all the necessary parameters for retrieving data and training the model

Returns

results: dict

FL results formatted as a dictionary. For example: results = {

“model_weights”: model_weights, “samples_count”: samples_count, “bias_weights”: fractions,

}