pdfcoffee

soumyasankar99
from soumyasankar99 More from this publisher
09.05.2023 Views

Chapter 13keras_model = …keras_model.compile(...)keras_federated_model = tff.learning.from_compiled_keras_model(keras_model, ..)2. Builders: This is the layer where the federated computation happens. Thereare two phases: compilation, where the learning algorithm is serialized intoan abstract representation of the computation, and execution, where therepresented computation is run.3. Datasets: This is a large collection of data that can be used to simulatefederated learning locally – a step useful for the initial fine tuning.We conclude this overview by mentioning that you can find a detailed description(https://www.tensorflow.org/federated/federated_learning) of APIsonline, and also a number of coding examples. The suggestion is to start by usingthe Colab notebook made available by Google (https://colab.research.google.com/github/tensorflow/federated/blob/v0.10.1/docs/tutorials/federated_learning_for_image_classification.ipynb). The framework allowsus to simulate the distributed training before running it on a real environment. Thelibrary in charge of FL learning is tensorflow_federated. Figure 12 discussed allthe steps used in federated learning with multiple nodes, and it might be usefulto better understand what has been discussed in this section. The next sectionwill introduce TensorFlow.js, a variant of TensorFlow that can be used natively inJavaScript:Figure 12: An example of federated learning with multiple nodes (source: https://upload.wikimedia.org/wikipedia/commons/e/e2/Federated_learning_process_central_case.png)[ 477 ]

TensorFlow for Mobile and IoT and TensorFlow.jsTensorFlow.jsTensorFlow.js is a JavaScript library for machine learning models that can workeither in vanilla mode or via Node.js. In this section we are going to review bothof them.Vanilla TensorFlow.jsTensorFlow.js is a JavaScript library for training and using Machine Learning (ML)models in a browser. It is derived from deeplearn.js, an open source, hardwareacceleratedlibrary for doing Deep Learning (DL) in JavaScript, and is now acompanion library to TensorFlow.The most common use of TensorFlow.js is to make pretrained ML/DL modelsavailable on the browser. This can help in situations where it may not be feasible tosend client data back to the server due to network bandwidth or security concerns.However, TensorFlow.js is a full stack ML platform, and it is possible to build andtrain an ML/DL model from scratch, as well as fine-tune an existing pretrainedmodel with new client data.An example of a TensorFlow.js application is the TensorFlow Projector (https://projector.tensorflow.org), which allows a client to visualize their own data (asword vectors) in 3-dimensional space, using one of several dimensionality reductionalgorithms provided. There are a few other examples of TensorFlow.js applicationslisted on the TensorFlow.js demo page (https://www.tensorflow.org/js/demos).Similarly to TensorFlow, TensorFlow.js also provides two main APIs – the OpsAPI, which exposes low-level tensor operations such as matrix multiplication, andthe Layers API, which exposes Keras-style high-level building blocks for neuralnetworks.At the time of writing, TensorFlow.js runs on three different backends. The fastest(and also the most complex) is the WebGL backend, which provides access toWebGL's low-level 3D graphics APIs and can take advantage of GPU hardwareacceleration. The other popular backend is the Node.js backend, which allows theuse of TensorFlow.js in server-side applications. Finally, as a fallback, there is theCPU-based implementation in plain JavaScript that will run in any browser.In order to gain a better understanding of how to write a TensorFlow.jsapplication, we will walk through an example of classifying MNIST digits usinga Convolutional Neural Network (CNN) provided by the TensorFlow.js team(https://storage.googleapis.com/tfjs-examples/mnist/dist/index.html).[ 478 ]

Chapter 13

keras_model = …

keras_model.compile(...)

keras_federated_model = tff.learning.from_compiled_keras_

model(keras_model, ..)

2. Builders: This is the layer where the federated computation happens. There

are two phases: compilation, where the learning algorithm is serialized into

an abstract representation of the computation, and execution, where the

represented computation is run.

3. Datasets: This is a large collection of data that can be used to simulate

federated learning locally – a step useful for the initial fine tuning.

We conclude this overview by mentioning that you can find a detailed description

(https://www.tensorflow.org/federated/federated_learning) of APIs

online, and also a number of coding examples. The suggestion is to start by using

the Colab notebook made available by Google (https://colab.research.

google.com/github/tensorflow/federated/blob/v0.10.1/docs/tutorials/

federated_learning_for_image_classification.ipynb). The framework allows

us to simulate the distributed training before running it on a real environment. The

library in charge of FL learning is tensorflow_federated. Figure 12 discussed all

the steps used in federated learning with multiple nodes, and it might be useful

to better understand what has been discussed in this section. The next section

will introduce TensorFlow.js, a variant of TensorFlow that can be used natively in

JavaScript:

Figure 12: An example of federated learning with multiple nodes (source: https://upload.wikimedia.org/

wikipedia/commons/e/e2/Federated_learning_process_central_case.png)

[ 477 ]

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

Saved successfully!

Ooh no, something went wrong!