FedDataset#

class fl_sim.data_processing.FedDataset[source]#

Bases: ReprMixin, CitationMixin, ABC

Base class for all federated datasets.

Methods that have to be implemented by subclasses:

  • get_dataloader

  • _preload

  • load_partition_data

  • load_partition_data_distributed

  • evaluate

Properties that have to be implemented by subclasses:

  • url

  • candidate_models

  • doi

abstract property candidate_models: Dict[str, Module]#

A set of candidate models.

property data_parts: List[str]#

Data part names.

abstract property doi: str | List[str]#

DOI(s) related to the dataset.

download_if_needed() None[source]#

Download data if needed.

abstract evaluate(probs: Tensor, truths: Tensor) Dict[str, float][source]#

Evaluation using predictions and ground truth.

extra_repr_keys() List[str][source]#

Extra keys for __repr__() and __str__().

abstract get_dataloader(train_bs: int, test_bs: int, client_idx: int | None = None) Tuple[DataLoader, DataLoader][source]#

Get dataloader for client client_idx or get global dataloader.

abstract load_partition_data(batch_size: int | None = None) tuple[source]#

Partition data into all local clients.

abstract load_partition_data_distributed(process_id: int, batch_size: int | None = None) tuple[source]#

Get local dataloader at client process_id or get global dataloader

abstract property url: str#

URL for downloading the dataset.