ibmfl.party
¶
Base Class¶
-
class
ibmfl.party.training.local_training_handler.
LocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ -
eval_model
(payload=None)[source]¶ Evaluate the local model based on the local test data.
- Parameters
payload (dict) – data payload received from Aggregator
- Returns
Dictionary of evaluation results
- Return type
dict
-
save_model
(payload=None)[source]¶ Save the local model.
- Parameters
payload (dict) – data payload received from Aggregator
- Returns
Status of save model request
- Return type
boolean
-
sync_model
(payload=None)[source]¶ Update the local model with global ModelUpdate received from the Aggregator.
- Parameters
payload (dict) – data payload received from Aggregator
- Returns
Status of sync model request
- Return type
boolean
-
Doc2Vec Local Training¶
-
class
ibmfl.party.training.doc2vec_local_training_handler.
Doc2VecLocalTrainingHandler
( fl_model, data_handler, hyperparams=None, **kwargs ) [source] ¶ Class implementation for Doc2Vec Local Training Handler.
-
__init__
( fl_model, data_handler, hyperparams=None, **kwargs ) [source] ¶ Initialize LocalTrainingHandler with fl_model, data_handler
- Parameters
-
fl_model (model.FLModel) – model to be trained
data_handler (DataHandler) – data handler that will be used to obtain data
hyperparams (dict) – Hyperparameters used for training.
kwargs (dict) – Additional arguments to initialize a local training handler.
- Returns
None
-
update_model
( model_update ) [source] ¶ Update local model with model updates received from FusionHandler
- Parameters
-
model_update (ModelUpdate) – model update
- Returns
None
-
train
( fit_params=None ) [source] ¶ Primary wrapper function used for routing internal remote function calls within the Local Training Handler functions.
- Parameters
-
fit_params (dict) – A dictionary payload structure containing two key signatures, `func` and `args`, which respectively are the target function defined within the Local Training Handler and the arguments defined within the executing function, which is defined as a dictionary containing key-value pairs of matching arguments.
- Returns
the corresponding values depending on the function remotely called from the aggregator
-
eval_model
( payload=None ) [source] ¶ Evaluate the local model based on data provided from the Aggregator
- Parameters
-
payload (dict) – data payload received from Aggregator
- Returns
list of evaluation results
- Return type
list
-
Federated Averaging Local Training¶
-
class
ibmfl.party.training.fedavg_local_training_handler.
FedAvgLocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶
FedPlus Local Training¶
-
class
ibmfl.party.training.fedplus_local_training_handler.
FedPlusLocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ -
update_model
(model_update)[source]¶ Update local model with model updates received from FusionHandler.
- Parameters
model_update (ModelUpdate)
- Returns
None
-
sync_model
(payload=None)[source]¶ Update the local model with global ModelUpdate received from the Aggregator.
- Parameters
payload (dict)
- Returns
Status of sync model request
- Return type
boolean
-
Gradient-Based Local Training¶
-
class
ibmfl.party.training.gradient_local_training_handler.
GradientLocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ Class for stochastic gradient descent based fusion algorithms. In this class, the aggregation is performed over gradients.
-
train
(fit_params)[source]¶ Retrieve the current gradient from party. With the provided model weights inside the fit_param, a model_weights including the current gradient information is generated and send through the connection.
- Parameters
fit_params (dict) – Query instruction containing a set of model weights from aggregator
- Returns
ModelUpdate
- Return type
ModelUpdate
-
PFNM Local Training¶
-
class
ibmfl.party.training.pfnm_local_training_handler.
PFNMLocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶
Reweigh Local Training¶
-
class
ibmfl.party.training.reweigh_local_training_handler.
ReweighLocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ -
__init__
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ Initialize LocalTrainingHandler with fl_model, data_handler.
- Parameters
fl_model (model.FLModel)
data_handler (DataHandler)
hyperparams (dict)
kwargs (str) - Additional arguments to initialize a local training handler, e.g., a crypto library object to help with encryption and decryption.
- Returns
None
-
train
(fit_params=None)[source]¶ Train locally using fl_model. At the end of training, a model_update with the new model information is generated and send through the connection.
- Parameters
fit_params (str) - (Optional) Query instruction from aggregator
- Returns
ModelUpdate
- Return type
ModelUpdate
-
Prejudice Remover Local Training¶
-
class
ibmfl.party.training.pr_local_training_handler.
PRLocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ -
__init__
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ Initialize LocalTrainingHandler with fl_model, data_handler.
- Parameters
fl_model (model.FLModel)
data_handler (DataHandler)
hyperparams (dict)
kwargs (str) - Additional arguments to initialize a local training handler, e.g., a crypto library object to help with encryption and decryption.
- Returns
None
-
RL Local Training¶
Module to where local training handler are implemented.
-
class
ibmfl.party.training.rl_local_training_handler.
RLLocalTrainingHandler
(fl_model, data_handler, hyperparams=None, **kwargs)[source]¶ Local training handler for RL
Party¶
-
class
ibmfl.party.party.
Party
(**kwargs)[source]¶ Application that runs FL at the party side. Given a config file, it spins a server, creates FLModel of the type that will be trained, creates an instance of the DataHandler to be used.
-
evaluate_model
()[source]¶ Calls function that evaluates current model with local testing data and prints the results.
- Returns
None
-
Party Protocol Handler¶
-
class
ibmfl.party.party_protocol_handler.
PartyProtocolHandler
(fl_model, connection, data_handler, local_training_handler, hyperparams=None, agg_info=None, synch=False)[source]¶ Base class for all PartyProtocolHandlers
-
execute_async
(id_request, msg)[source]¶ Handle run in a different thread to allow asynchronous requests.
- Parameters
msg (Message) – Message object form connection
-
get_handle
(message_type)[source]¶ Get handler for given message type.
- Parameters
message_type (int) – request message type
- Returns
a handler which was assigned for given message type
-
handle_async_request
(msg)[source]¶ - Handle all incoming requests asynchronously and route it to respective
methods in local training handler.
- Parameters
msg (Message) – Message object form connection
- Returns
Response message sent back to requester
- Return type
ResponseMessage
-
Status Type¶
An enumeration class for the message type field which describe party status
Metrics Recorder¶
ibmfl.party.metrics.metrics_recorder.
MetricsEntry
()[source]¶Stores metrics for one round. The each round has values that can be added at the respective hook. The hooks should only fill their values and can use any keys they like (for now).
ibmfl.party.metrics.metrics_recorder.
MetricsRecorder
()[source]¶Stores metrics for one round. The each round has values that can be added at the respective hook. The hooks should only fill their values and can use any keys they like (for now).
-
__init__
()[source]¶ Just initializes a dictionary for each hook and creates a variable to keep track of which round this entry corresponds to.
- Returns
None
-
pre_update_hook
()[source]¶ Fill in the pre_update dictionary of the latest entry; for now we just take timestamps.
- Returns
None
-
post_update_hook
()[source]¶ Fill in the post_update dictionary of the latest entry; for now we just take timestamps.
- Returns
None