Federated Learning with NumPy and Flower (Quickstart Example)ΒΆ
This example of Flower uses a dummy NumPy model as well as dummy training and evaluation steps in the ClientApp to showcase the core functionality of Flower apps. This app does not use a dataset.
Set up the projectΒΆ
Fetch the appΒΆ
Install Flower:
pip install flwr
Fetch the app:
flwr new @flwrlabs/quickstart-numpy
quickstart-numpy
βββ quickstart_numpy
β βββ __init__.py
β βββ client_app.py # Defines your ClientApp
β βββ server_app.py # Defines your ServerApp
β βββ task.py # Defines model creation
βββ pyproject.toml # Project metadata like dependencies and configs
βββ README.md
Install dependencies and projectΒΆ
Install the dependencies defined in pyproject.toml as well as the quickstart_numpy package.
pip install -e .
Tip: Your
pyproject.tomlfile can define more than just the dependencies of your Flower app. You can also use it to specify hyperparameters for your runs and control which Flower Runtime is used. By default, it uses the Simulation Runtime, but you can switch to the Deployment Runtime when needed. Learn more in the TOML configuration guide.
Run with the Simulation EngineΒΆ
In the quickstart-numpy directory, use flwr run to run a local simulation:
flwr run .
Refer to the How to Run Simulations guide in the documentation for advice on how to optimize your simulations.
Run with the Deployment EngineΒΆ
Follow this how-to guide to run the same app in this example but with Flowerβs Deployment Engine. After that, you might be interested in setting up secure TLS-enabled communications and SuperNode authentication in your federation.
You can run Flower on Docker too! Check out the Flower with Docker documentation.
ResourcesΒΆ
Flower website: flower.ai
Check the documentation: flower.ai/docs
Give Flower a βοΈ on GitHub: GitHub
Join the Flower community!
