Flower: A Friendly Federated Learning Framework

A unified approach to federated learning. Federate any workload, any ML framework, and any programming language.

pip install flwr
Flower Logo

Who is using it?

Some of the best research institutes in the world use Flower

logo oxford
logo cambridge
logo ucl
logo avignon
logo rwth_aachen
logo tsinghua
logo nokia_bell_labs
logo speechbrain
logo samsung
logo oxford
logo cambridge
logo ucl
logo avignon
logo rwth_aachen
logo tsinghua
logo nokia_bell_labs
logo speechbrain
logo samsung

Why Flower?

Scalability

Flower was built to encounter real-world setups with a large number of clients. Researchers used Flower to run workloads with more than 10.000 clients.

ML Frameworks

Flower is compatible with a wide range of existing and future Machine Learning frameworks. You love Keras? Great. You prefer PyTorch? Awesome. Raw NumPy, no automatic differentiation? You rock!

Mobile, Edge & Beyond

Flower enables research on all kinds of servers and devices, including mobile. Android, iOS, Raspberry Pi, Nvidia Jetson, all compatible with Flower.

Proven Infrastructure

Flower provides federated learning infrastructure to ensure low engineering effort which enables you to concentrate on your own ML use case.

Platform Independent

Flower is interoperable with different operating systems and hardware platforms to work well heterogeneous edge device environments.

Usability

It's easy to get started. 20 lines of Python is enough to build a full federated learning system in TensorFlow. See the TensorFlow/Keras, PyTorch, or MXNet examples to get started.

Flower Usage Example

server.py

Copy
import flwr as fl

# Start Flower server for three rounds of federated learning
fl.server.start_server(config={"num_rounds": 3})

client.py

Copy
import flwr as fl
import tensorflow as tf

# Load and compile Keras model
model = tf.keras.applications.MobileNetV2((32, 32, 3), classes=10, weights=None)
model.compile("adam", "sparse_categorical_crossentropy", metrics=["accuracy"])

# Load CIFAR-10 dataset
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.cifar10.load_data()

# Define Flower client
class CifarClient(fl.client.NumPyClient):
    def get_parameters(self):
        return model.get_weights()

    def fit(self, parameters, config):
        model.set_weights(parameters)
        model.fit(x_train, y_train, epochs=1, batch_size=32, steps_per_epoch=3)
        return model.get_weights(), len(x_train), {}

    def evaluate(self, parameters, config):
        model.set_weights(parameters)
        loss, accuracy = model.evaluate(x_test, y_test)
        return loss, len(x_test), {"accuracy": accuracy}

# Start Flower client
fl.client.start_numpy_client(server_address="[::]:8080", client=CifarClient())

Getting Started

Installation Guide

The Flower documentation has detailed instructions on what you need to install Flower and how you install it. Spoiler alert: you only need pip! Check out our installation guide.

Tensorflow, PyTorch, and MXNet

Do you already use TensorFlow, PyTorch, or MXNet? Then you can simply follow our quickstart examples that make it easy to federate your existing machine learning workloads.

Support Flower

Flower Merch!

Flower is an open-source project built and maintained by volunteers. If you want to support the development and even get something in return (apart from new features!), check out the Flower Merch store. 100% of the returns from Flower Merch go into open-source development.

Flower Logo
Flower Logo

Follow us!

Join us on our journey to connect fleet devices and be part of the future of machine learning.