Skip to content

taps.apps.configs.fedlearn

FedlearnConfig

Bases: AppConfig

Federated learning application configuration.

Parameters:

  • name (Literal[str], default: 'fedlearn' ) –

    Application name.

  • alpha (float, default: 100000.0 ) –

    Alpha parameter for number of samples across clients.

  • dataset (DataChoices, default: <DataChoices.MNIST: 'mnist'> ) –

    Training and testing dataset.

  • data_dir (Path, default: PosixPath('data/fedlearn') ) –

    Dataset download directory.

  • device (str, default: 'cpu' ) –

    Device to use (e.g., cpu or cuda).

  • clients (int, default: 8 ) –

    Number of simulated clients.

  • rounds (int, default: 3 ) –

    Number of aggregation rounds.

  • participation (float, default: 1.0 ) –

    Fraction of participating clients in each round.

  • epochs (int, default: 3 ) –

    Number of epochs for local training.

  • lr (float, default: 0.001 ) –

    Learning rate for local training.

  • batch_size (int, default: 3 ) –

    Batch size for local training.

  • train (bool, default: True ) –

    Flag for performing training (false will use no-op training tasks).

  • test (bool, default: True ) –

    Evaluate the global model on test data after each round.

  • seed (int | None, default: None ) –

    Random seed.

get_app

get_app() -> App

Create an application instance from the config.

Source code in taps/apps/configs/fedlearn.py
def get_app(self) -> App:
    """Create an application instance from the config."""
    from taps.apps.fedlearn.app import FedlearnApp
    from taps.apps.fedlearn.types import DataChoices

    return FedlearnApp(
        clients=self.clients,
        rounds=self.rounds,
        device=self.device,
        epochs=self.batch_size,
        batch_size=self.batch_size,
        lr=self.lr,
        dataset=DataChoices(self.dataset),
        data_dir=self.data_dir,
        train=self.train,
        test=self.test,
        participation=self.participation,
        seed=self.seed,
    )