pdfcoffee

soumyasankar99
from soumyasankar99 More from this publisher
09.05.2023 Views

Chapter 13Traditional machine learning requires you to have a centralized repository fortraining data either on your desktop, or in your datacenter, or in the cloud. Federatedlearning pushes the training phase at the edge by distributing the computationamong millions of mobile devices. These devices are ephemeral in that they arenot always available for the learning process and they can disappear silently (forinstance, a mobile phone can be switched off all of a sudden). The key idea isto leverage the CPUs and the GPU of each mobile phone that is made availablefor an FL computation. Each mobile device forming a part of a distributed FLtraining downloads a (pretrained) model from a central server and it performslocal optimization based on the local training data collected on each specificmobile device. This process is similar to the transfer learning process (see Chapter5, Advanced Convolutional Neural Networks), but it is distributed at the edge. Eachlocally updated model is then sent back by millions of edge devices to a centralserver to build an averaged shared model.Of course, there are many issues to be considered. Let's review them:1. Battery usage: Each mobile device that is part of an FL computationshould save as much as possible on local battery usage.2. Encrypted communication: Each mobile device belonging to an FLcomputation has to use encrypted communication with the central server toupdate the locally built model.3. Efficient communication: Typically, deep learning models are optimizedwith optimization algorithms such as SGD (see Chapter 1, Neural NetworkFoundations with TensorFlow 2.0, and Chapter 15, The Math Behind DeepLearning). However, FL works with millions of devices and there istherefore a strong need to minimize the communication patterns. Googleintroduced a Federated Averaging algorithm [8], which is reported to reducethe amount of communication 10x-100x when compared with vanilla SGD.Plus, compression techniques [9] reduce the communication costs by anadditional 100x with random rotations and quantization.4. Ensure user privacy: This is probably the most important point. All localtraining data acquired at the edge must stay at the edge. This means that thetraining data acquired on a mobile device cannot be sent to a central server.Equally important, any user behavior learned in locally trained models mustbe anonymized so that it is not possible to understand any specific actionperformed by specific individuals.Figure 11 shows a typical FL architecture (source [10]). An FL Server sends a modeland a training plan to millions of devices. The training plan includes information onhow frequently updates are expected and other metadata.[ 475 ]

TensorFlow for Mobile and IoT and TensorFlow.jsEach device runs the local training and sends a model update back to the globalservices. Note that each device has an FL runtime providing federated learningservices to an app process that stores data in a local example store. The FL runtimefetches the training examples from the example store:Figure 11: An example of federated learning architectureTensorFlow FL APIsThe TensorFlow Federated (TTF) platform has two layers:• Federated learning (FL), a high-level interface that works well withtf.keras and non tf.keras models. In the majority of situations you willuse this API for distributed training that is privacy preserving.• Federated core (FC), a low-level interface that is highly customizable andallows you to interact with low level communications and with federatedalgorithms. You will need this API only if you intend to implement new andsophisticated distributed learning algorithms. This topic is rather advanced,and we are not going to cover it in this book. If you wish to learn more,you can find more information online (https://www.tensorflow.org/federated/federated_core).The FL API has three key parts:1. Models: Used to wrap existing models for enabling federating learning.This can be achieved via the tff.learning.from_keras_model(), or viasubclassing of tff.learning.Model(). For instance, you can have thefollowing code fragment:[ 476 ]

Chapter 13

Traditional machine learning requires you to have a centralized repository for

training data either on your desktop, or in your datacenter, or in the cloud. Federated

learning pushes the training phase at the edge by distributing the computation

among millions of mobile devices. These devices are ephemeral in that they are

not always available for the learning process and they can disappear silently (for

instance, a mobile phone can be switched off all of a sudden). The key idea is

to leverage the CPUs and the GPU of each mobile phone that is made available

for an FL computation. Each mobile device forming a part of a distributed FL

training downloads a (pretrained) model from a central server and it performs

local optimization based on the local training data collected on each specific

mobile device. This process is similar to the transfer learning process (see Chapter

5, Advanced Convolutional Neural Networks), but it is distributed at the edge. Each

locally updated model is then sent back by millions of edge devices to a central

server to build an averaged shared model.

Of course, there are many issues to be considered. Let's review them:

1. Battery usage: Each mobile device that is part of an FL computation

should save as much as possible on local battery usage.

2. Encrypted communication: Each mobile device belonging to an FL

computation has to use encrypted communication with the central server to

update the locally built model.

3. Efficient communication: Typically, deep learning models are optimized

with optimization algorithms such as SGD (see Chapter 1, Neural Network

Foundations with TensorFlow 2.0, and Chapter 15, The Math Behind Deep

Learning). However, FL works with millions of devices and there is

therefore a strong need to minimize the communication patterns. Google

introduced a Federated Averaging algorithm [8], which is reported to reduce

the amount of communication 10x-100x when compared with vanilla SGD.

Plus, compression techniques [9] reduce the communication costs by an

additional 100x with random rotations and quantization.

4. Ensure user privacy: This is probably the most important point. All local

training data acquired at the edge must stay at the edge. This means that the

training data acquired on a mobile device cannot be sent to a central server.

Equally important, any user behavior learned in locally trained models must

be anonymized so that it is not possible to understand any specific action

performed by specific individuals.

Figure 11 shows a typical FL architecture (source [10]). An FL Server sends a model

and a training plan to millions of devices. The training plan includes information on

how frequently updates are expected and other metadata.

[ 475 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!