nvflare.app_common.np.recipes.lr.fedavg module

class FedAvgLrRecipe(*, name: str = 'lr_fedavg', num_rounds: int = 2, damping_factor=0.8, num_features=13, train_script: str, train_args: str = '', launch_external_process=False, command: str = 'python3 -u')[source]

Bases: Recipe

A recipe for implementing Federated Averaging (FedAvg) for Logistics Regression with Newton Raphson. FedAvg is a fundamental federated learning algorithm that aggregates model updates from multiple clients by computing a weighted average based on the amount of local training data. This recipe sets up a complete federated learning workflow with scatter-and-gather communication pattern.

The recipe configures: - A federated job with initial model (optional) - Weighted aggregator for combining client model updates (or custom aggregator) - Script runners for client-side training execution

Parameters:
  • name – Name of the federated learning job. Defaults to “lr_fedavg”.

  • num_rounds – Number of federated training rounds to execute. Defaults to 2.

  • damping_factor – default to 0.8

  • train_script – Path to the training script that will be executed on each client.

  • train_args – Command line arguments to pass to the training script.

  • launch_external_process (bool) – Whether to launch the script in external process. Defaults to False.

  • command (str) – If launch_external_process=True, command to run script (prepended to script). Defaults to “python3”.

Example

```python
recipe = FedAvgLrRecipe(num_rounds=num_rounds,

damping_factor=0.8, num_features=13, train_script=”client.py”, train_args=f”–data_root {data_root}”)

```

This is base class of a recipe. Recipes are implemented by jobs. A concrete recipe must provide the job for recipe implementation.

Parameters:

job – the job that implements the recipe.