syft.frameworks.torch.fl¶
Submodules¶
Package Contents¶
-
class
syft.frameworks.torch.fl.BaseDataset(data, targets, transform=None)¶ This is a base class to be used for manipulating a dataset. This is composed of a .data attribute for inputs and a .targets one for labels. It is to be used like the MNIST Dataset object, and is useful to avoid handling the two inputs and label tensors separately.
- Parameters
tensors] (data[list,torch) – the data points
targets – Corresponding labels of the data points
transform – Function to transform the datapoints
-
fix_precision¶
-
float_precision¶
-
__len__(self)¶
-
__getitem__(self, index)¶ - Parameters
index[integer] – index of item to get
- Returns
Data points corresponding to the given index targets: Targets correspoding to given datapoint
- Return type
data
-
transform(self, transform)¶ Allows a transform to be applied on given dataset. :param transform: The transform to be applied on the data
-
send(self, worker)¶ - Parameters
class] (worker[worker) – worker to which the data must be sent
- Returns
Return the object instance with data sent to corresponding worker
- Return type
self
-
get(self)¶ Gets the data back from respective workers.
-
fix_prec(self, *args, **kwargs)¶ Converts data of BaseDataset into fixed precision
-
float_prec(self, *args, **kwargs)¶ Converts data of BaseDataset into float precision
Share the data with the respective workers
-
property
location(self)¶ Get location of the data
-
class
syft.frameworks.torch.fl.FederatedDataset(datasets)¶ -
property
workers(self)¶ Returns: list of workers
-
__getitem__(self, worker_id)¶ - Parameters
worker_id[str,int] – ID of respective worker
Returns: Get Datasets from the respective worker
-
__len__(self)¶
-
__repr__(self)¶
-
property
-
class
syft.frameworks.torch.fl.FederatedDataLoader(federated_dataset, batch_size=8, shuffle=False, num_iterators=1, drop_last=False, collate_fn=default_collate, iter_per_worker=False, **kwargs)¶ Bases:
objectData loader. Combines a dataset and a sampler, and provides single or several iterators over the dataset.
- Parameters
federated_dataset (FederatedDataset) – dataset from which to load the data.
batch_size (int, optional) – how many samples per batch to load (default:
1).shuffle (bool, optional) – set to
Trueto have the data reshuffled at every epoch (default:False).collate_fn (callable, optional) – merges a list of samples to form a mini-batch.
drop_last (bool, optional) – set to
Trueto drop the last incomplete batch, if the dataset size is not divisible by the batch size. IfFalseand the size of dataset is not divisible by the batch size, then the last batch will be smaller. (default:False)num_iterators (int) – number of workers from which to retrieve data in parallel. num_iterators <= len(federated_dataset.workers) - 1 the effect is to retrieve num_iterators epochs of data but at each step data from num_iterators distinct workers is returned.
iter_per_worker (bool) – if set to true, __next__() will return a dictionary containing one batch per worker
-
__initialized= False¶
-
__iter__(self)¶
-
__next__(self)¶
-
__len__(self)¶