flox.clients.MainClient.MainClient¶
- class MainClient[source]¶
Bases:
FloxClientLogicMethods
get_number_of_sampleson_data_processRetrieves data for training the model.
Fit the provided global model using a local dataset
Parses & decrypts the received data from a controller
Final data processing before sending the results back, such as encryption.
retrieve_framework_dataRetrieves x_train and y_train from given paths of .npy files Overwrite this function if you need to retrieve your locally stored data differently
Combines the rest of the functions to run a single Federated Learning round
- on_data_retrieve(config)[source]¶
Retrieves data for training the model.
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()¶
Fit the provided global model using a local dataset
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_send(fit_results, training_data=None, config=None, task_runtime=None, task_start_timestamp=None, task_finish_timestamp=None, data_processing_runtime=None, training_runtime=None, endpoint_physical_cores=None, endpoint_logical_cores=None, endpoint_physical_memory=None, platform_name=None)[source]¶
Final data processing before sending the results back, such as encryption.
Returns¶
- results: dict
FL results formatted as a dictionary. For example: results = {
“model_weights”: model_weights, “samples_count”: samples_count, “bias_weights”: fractions,
}
- retrieve_local_data(config)[source]¶
Retrieves x_train and y_train from given paths of .npy files Overwrite this function if you need to retrieve your locally stored data differently
- Return type:
Parameters¶
- config: dict
dictionary with values indicating the path directory and file names for x_ and y_train data
Returns¶
- raw_training_data: Tuple(NDArrays, NDArrays)
x_train and y_train returned as a tuple
- run_round(config, model_trainer)[source]¶
Combines the rest of the functions to run a single Federated Learning round
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,
}