@sarah/quickstart-tensorflow-timeseries
flwr new @sarah/quickstart-tensorflow-timeseriesFederated Learning with Tensorflow and Flower
This introductory Flower example uses Tensorflow for timeseries regression, but deep knowledge of Tensorflow is not required to run it. The example is easy to run and helps illustrate how Flower can be adapted to your own use case. It uses Flower Datasets to download, partition, and preprocess the Jena-Climate dataset.
Fetch the App
Install Flower:
pip install flwr
Fetch the app:
flwr new @sarah/quickstart-tensorflow-timeseries
This will create a new directory called quickstart-tensorflow-timeseries with the following structure:
- quickstart-tensorflow-timeseries - tftsexample - __init__.py - client_app.py # Defines your ClientApp - server_app.py # Defines your ServerApp - task.py # Defines your model, training and data loading - pyproject.toml # Project metadata like dependencies and configs - README.md
Run the App
You can run your Flower App in both simulation and deployment mode without making changes to the code. If you are starting with Flower, we recommend you using the simulation mode as it requires fewer components to be launched manually. By default, flwr run will make use of the Simulation Engine.
Run with the Simulation Engine
TIP
Check the Simulation Engine documentation to learn more about Flower simulations, how to use more virtual SuperNodes, and how to configure CPU/GPU usage in your ClientApp.
Install the dependencies defined in pyproject.toml package.
cd quickstart-tensorflow-timeseries && pip install -e .
Run with default settings:
flwr run .
You can also override some of the settings for your ClientApp and ServerApp defined in pyproject.toml. For example:
flwr run . --run-config "num-server-rounds=5 learning-rate=0.05"
Run with the Deployment Engine
To run this App using Flower's Deployment Engine we recommend first creating some demo data using Flower Datasets. For example:
# Install Flower datasets pip install "flwr-datasets['vision']" # Create dataset partitions and save them to disk flwr-datasets create sayanroy058/Jena-Climate --num-partitions 2 --out-dir demo_data
The above command will create two IID partitions of the Jena-climate dataset and save them in a demo_data directory. Next, you can pass one partition to each of your SuperNodes like this:
flower-supernode \ --insecure \ --superlink <SUPERLINK-FLEET-API> \ --node-config="data-path=/path/to/demo_data/partition_0"
Finally, ensure the environment of each SuperNode has all dependencies installed. Then, launch the run via flwr run but pointing to a SuperLink connection that specifies the SuperLink your SuperNode is connected to:
flwr run . <SUPERLINK-CONNECTION> --stream
TIP
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.