Introduction to Federated Learning.

Introduction to decentralized federated learning.
type: tutoriallevel: mediumguides: decai_fl

Federated Learning is a fascinating and upsurging Machine Learning technique for learning on decentralized data. The core idea is that a training dataset can remain in the hands of its producers (also known as workers), which helps improve privacy and ownership while the model is shared between workers.

In this tutorial, we will give an overview of federated learning, definitions, and implementation.

Summary: Simple code examples make learning easy. Here, we use the MNIST training task to introduce Federated Learning the easy way.


  1. Install required dependencies

    $ /usr/bin/ruby -e "$(curl -fsSL"
    $ export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
    $ brew update
    $ brew install python # Python 3
    $ sudo pip3 install --user --upgrade virtualenv
  2. Install Tensorflow

    Let's implement a federated learning algorithm in Python with Tensorflow:

    $ virtualenv --python python3 "venv"
    $ source "venv/bin/activate"
    $ pip install --upgrade pip
    $ pip install tensorflow
    $ pip install --upgrade tensorflow-federated

Once the prerequisites are installed, you can start to build your AI Network.

Compiling AI Network

Firstly, you need to compile the source code.

  1. Clone the source code

    git clone
  2. Compile the source code

    cd LDR_ALDK
    pip install -r requirements.txt

Next Step

You have got the basis of federated learning, let's keep moving.

Your next step may be:

  • Develop your first federated learning algorithm.
View Development Tutorial
  • Deploy your application.
View Deployment Guide

If you experienced any issues with this tutorial or want to provide feedback, feel free to open a GitHub issue or reach out on Slack.