pdfcoffee
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 ]
- Page 460 and 461: Chapter 11else:return np.argmax(sel
- Page 462 and 463: Chapter 11DQN to play a game of Ata
- Page 464 and 465: Chapter 11self.model.add( Conv2D(64
- Page 466 and 467: Chapter 11Here the action A was sel
- Page 468 and 469: Chapter 11Image source: https://arx
- Page 470 and 471: Chapter 11A neural network is used
- Page 472: Chapter 1111. Details regarding ins
- Page 475 and 476: TensorFlow and Cloud• Scalability
- Page 477 and 478: TensorFlow and Cloud• Azure DevOp
- Page 479 and 480: TensorFlow and Cloud• Lambda: The
- Page 481 and 482: TensorFlow and Cloud• Deep Learni
- Page 483 and 484: TensorFlow and CloudEC2 on AmazonTo
- Page 485 and 486: TensorFlow and CloudCompute Instanc
- Page 487 and 488: TensorFlow and CloudYou just share
- Page 489 and 490: TensorFlow and CloudIn case you req
- Page 491 and 492: TensorFlow and CloudIt starts with
- Page 493 and 494: TensorFlow and CloudTFX librariesTF
- Page 495 and 496: TensorFlow and CloudReferences1. To
- Page 497 and 498: TensorFlow for Mobile and IoT and T
- Page 499 and 500: TensorFlow for Mobile and IoT and T
- Page 501 and 502: TensorFlow for Mobile and IoT and T
- Page 503 and 504: TensorFlow for Mobile and IoT and T
- Page 505 and 506: TensorFlow for Mobile and IoT and T
- Page 507 and 508: TensorFlow for Mobile and IoT and T
- Page 509: TensorFlow for Mobile and IoT and T
- Page 513 and 514: TensorFlow for Mobile and IoT and T
- Page 515 and 516: TensorFlow for Mobile and IoT and T
- Page 517 and 518: TensorFlow for Mobile and IoT and T
- Page 519 and 520: TensorFlow for Mobile and IoT and T
- Page 521 and 522: TensorFlow for Mobile and IoT and T
- Page 523 and 524: TensorFlow for Mobile and IoT and T
- Page 525 and 526: TensorFlow for Mobile and IoT and T
- Page 527 and 528: An introduction to AutoMLThat is pr
- Page 529 and 530: An introduction to AutoMLFeature co
- Page 531 and 532: An introduction to AutoMLThis Effic
- Page 533 and 534: An introduction to AutoMLGoogle Clo
- Page 535 and 536: An introduction to AutoMLThen, we c
- Page 537 and 538: An introduction to AutoMLOnce the d
- Page 539 and 540: An introduction to AutoMLIf your mo
- Page 541 and 542: An introduction to AutoMLClicking o
- Page 543 and 544: An introduction to AutoMLFigure 16:
- Page 545 and 546: An introduction to AutoMLYou can al
- Page 547 and 548: An introduction to AutoMLPut simply
- Page 549 and 550: An introduction to AutoMLLet's star
- Page 551 and 552: An introduction to AutoMLThe token
- Page 553 and 554: An introduction to AutoMLThis will
- Page 555 and 556: An introduction to AutoMLFigure 37:
- Page 557 and 558: An introduction to AutoMLAt the end
- Page 559 and 560: An introduction to AutoMLUsing Clou
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 ]