taps.apps.fedlearn.app¶
FedlearnApp
¶
FedlearnApp(
clients: int,
rounds: int,
dataset: DataChoices,
batch_size: int,
epochs: int,
lr: float,
data_dir: Path,
device: str = "cpu",
download: bool = False,
train: bool = True,
test: bool = True,
alpha: float = 100000.0,
participation: float = 1.0,
seed: int | None = None,
)
Federated learning application.
Parameters:
-
clients
(int
) –Number of simulated clients.
-
rounds
(int
) –Number of aggregation rounds to perform.
-
dataset
(DataChoices
) –Dataset (and corresponding model) to use.
-
batch_size
(int
) –Batch size used for local training across all clients.
-
epochs
(int
) –Number of epochs used during local training on all the clients.
-
lr
(float
) –Learning rate used during local training on all the clients.
-
data_dir
(Path
) –Root directory where the dataset is stored or where you wish to download the data (i.e.,
download=True
). -
device
(str
, default:'cpu'
) –Device to use for model training (e.g.,
'cuda'
,'cpu'
,'mps'
). -
train
(bool
, default:True
) –If
True
(default), the local training will be run. If `False, then a no-op version of the application will be performed where no training is done. This is useful for debugging purposes. -
test
(bool
, default:True
) –If
True
(default), model testing is done at the end of each aggregation round. -
alpha
(float
, default:100000.0
) –The number of data samples across clients is defined by a Dirichlet distribution. This value is used to define the uniformity of the amount of data samples across all clients. When data alpha is large, then the number of data samples across clients is uniform (default). When the value is very small, then the sample distribution becomes more non-uniform. Note: this value must be greater than 0.
-
participation
(float
, default:1.0
) –The portion of clients that participate in an aggregation round. If set to 1.0, then all clients participate in each round; if 0.5 then half of the clients, and so on. At least one client will be selected regardless of this value and the number of clients.
-
seed
(int | None
, default:None
) –Seed for reproducibility.
Source code in taps/apps/fedlearn/app.py
close
¶
run
¶
Run the application.
Parameters: