syft.federated.train_config¶
Module Contents¶
-
class
syft.federated.train_config.TrainConfig(model: torch.jit.ScriptModule, loss_fn: torch.jit.ScriptModule, owner: AbstractWorker = None, batch_size: int = 32, epochs: int = 1, optimizer: str = 'SGD', optimizer_args: dict = {'lr': 0.1}, id: Union[int, str] = None, max_nr_batches: int = -1, shuffle: bool = True, loss_fn_id: int = None, model_id: int = None)¶ TrainConfig abstraction.
A wrapper object that contains all that is needed to run a training loop remotely on a federated learning setup.
-
__str__(self)¶ Returns the string representation of a TrainConfig.
-
_wrap_and_send_obj(self, obj, location)¶ Wrappers object and send it to location.
-
send(self, location: BaseWorker)¶ Gets the pointer to a new remote object.
One of the most commonly used methods in PySyft, this method serializes the object upon which it is called (self), sends the object to a remote worker, creates a pointer to that worker, and then returns that pointer from this function.
- Parameters
location – The BaseWorker object which you want to send this object to. Note that this is never actually the BaseWorker but instead a class which instantiates the BaseWorker abstraction.
- Returns
A weakref instance.
-
get(self, location)¶
-
get_model(self)¶
-
get_loss_fn(self)¶
-
static
simplify(worker: AbstractWorker, train_config: TrainConfig)¶ Takes the attributes of a TrainConfig and saves them in a tuple.
Attention: this function does not serialize the model and loss_fn attributes of a TrainConfig instance, these are serialized and sent before. TrainConfig keeps a reference to the sent objects using _model_id and _loss_fn_id which are serialized here.
- Parameters
worker – the worker doing the serialization
train_config – a TrainConfig object
- Returns
a tuple holding the unique attributes of the TrainConfig object
- Return type
tuple
-
static
detail(worker: AbstractWorker, train_config_tuple: tuple)¶ This function reconstructs a TrainConfig object given it’s attributes in the form of a tuple.
- Parameters
worker – the worker doing the deserialization
train_config_tuple – a tuple holding the attributes of the TrainConfig
- Returns
A TrainConfig object
- Return type
train_config
-