Book Image

Deep Learning with TensorFlow 2 and Keras - Second Edition

By : Antonio Gulli, Amita Kapoor, Sujit Pal
Book Image

Deep Learning with TensorFlow 2 and Keras - Second Edition

By: Antonio Gulli, Amita Kapoor, Sujit Pal

Overview of this book

Deep Learning with TensorFlow 2 and Keras, Second Edition teaches neural networks and deep learning techniques alongside TensorFlow (TF) and Keras. You’ll learn how to write deep learning applications in the most powerful, popular, and scalable machine learning stack available. TensorFlow is the machine learning library of choice for professional applications, while Keras offers a simple and powerful Python API for accessing TensorFlow. TensorFlow 2 provides full Keras integration, making advanced machine learning easier and more convenient than ever before. This book also introduces neural networks with TensorFlow, runs through the main applications (regression, ConvNets (CNNs), GANs, RNNs, NLP), covers two working example apps, and then dives into TF in production, TF mobile, and using TensorFlow with AutoML.
Table of Contents (19 chapters)
17
Other Books You May Enjoy
18
Index

Using TensorFlow 2.1 and nightly build

As of November 2019, you can get full TPU support only with the latest TensorFlow 2.x nightly build. If you use the Google Cloud Console (https://console.cloud.google.com/) you can get the latest nightly build. Just, go to Compute Engine | TPUs | CREATE TPU NODE. The version selector has a "nightly-2.x" option. Martin Görner has a nice demo at http://bit.ly/keras-tpu-tf21 (see Figure 13). This is used for classifying images of flowers:

Figure 13: Martin Görner on Twitter on Full Keras/TPU support

Note that both Regular Keras using model.fit() and custom training loop, distributed are supported. You can refer tohttp://bit.ly/keras-tpu-tf21. Let's look at the most important parts of the code related to TPUs. First at all, the imports:

import re
import tensorflow as tf
import numpy as np
from matplotlib import pyplot as plt
print("Tensorflow version " + tf.__version__)

Then the detection...