Skip to main content

federated_training

Algorithm to train a model remotely and return its parameters.

Classes

FederatedModelTraining

class FederatedModelTraining(    *,    model: _DistributedModelTypeOrReference,    modeller_checkpointing: bool = True,    checkpoint_filename: Optional[str] = None,    pretrained_file: Optional[Union[str, os.PathLike]] = None,    project_id: Optional[str] = None,):

Algorithm for training a model remotely and returning its updated parameters.

This algorithm is designed to be compatible with the FederatedAveraging protocol.

Arguments

  • model: The model to train on remote data.
  • pretrained_file: A file path or a string containing a pre-trained model. Defaults to None.

Attributes

  • checkpoint_filename: The filename for the last checkpoint. Defaults to the task id and the last iteration number, i.e., {taskid}-iteration-{iteration_number}.pt.
  • class_name: The name of the algorithm class.
  • fields_dict: A dictionary mapping all attributes that will be serialized in the class to their marshamllow field type. (e.g. fields_dict = {"class_name": fields.Str()}).
  • model: The model to train on remote data.
  • modeller_checkpointing: Whether to save the last checkpoint on the modeller side. Defaults to True.
  • nested_fields: A dictionary mapping all nested attributes to a registry that contains class names mapped to the respective classes. (e.g. nested_fields = {"datastructure": datastructure.registry})
  • pretrained_file: A file path or a string containing a pre-trained model. Defaults to None.

Ancestors

  • bitfount.federated.algorithms.model_algorithms.base._BaseModelAlgorithmFactory
  • BaseAlgorithmFactory
  • abc.ABC
  • bitfount.federated.roles._RolesMixIn
  • bitfount.types._BaseSerializableObjectMixIn

Variables

  • static nested_fields : ClassVar[Dict[str, Mapping[str, Any]]]

Methods


create

def create(self, role: Union[str, Role], **kwargs: Any)> Any:

Create an instance representing the role specified.

modeller

def modeller(    self, **kwargs: Any,)> bitfount.federated.algorithms.model_algorithms.federated_training._ModellerSide:

Returns the modeller side of the FederatedModelTraining algorithm.

worker

def worker(    self, hub: BitfountHub, **kwargs: Any,)> bitfount.federated.algorithms.model_algorithms.federated_training._WorkerSide:

Returns the worker side of the FederatedModelTraining algorithm.

Arguments

  • hub: BitfountHub object to use for communication with the hub.