Deep Learning With Tensorflow 2 and Keras
Deep Learning With Tensorflow 2 and Keras
Second Edition
Antonio Gulli
Amita Kapoor
Sujit Pal
02 07
02349
Packt
BIRMINGHAM -MUMBAI
Deep Learning with TensorFlow 2 and Keras
Second Edition
All No
part of this book may
be reproduced, stored in a retrieval
rights reserved.
or transmitted in any form or by any means, without the prior written
system,
of the publisher, case of brief quotations embedded in
permission except in the
2017
First published: April
Second edition: December 2019
Production reference:2130320
ISBN 978-1-83882-341-2
www.packt.com
Packt2
packt.com
Subscribe to our online digital library for full access to over 7,000 booksand videos,
well as industry tools and
as leading to help you plan your personal development
advance your career. For more information,please visit our website.
Why subscribe?
time learning and more time coding with practical eBooks and
Spend less
Videos from over 4,000 industry professionals
Learn better with Skill Plans built especially for you
Get a free eBook or video every month
At www. Packt.com, you can also reada collection of free technical articles, sign up
newsletters,and receive exclusive discounts and offers on Packt
for a range of free
books and eBooks.
Table of Contents
Preface
Chapter 1: Neural Network Foundations with TensorFlow 2.0
What is TensorFlow (TF)?
What is Keras?
What are the most important changes in TensorFlow 2.07
Introduction to neural networks
Perceptron
A first example of TensorFlow 2.0 code
Multi-layer perceptron our first example of a network
Problems in training the perceptron and their solutions
Activation function sigmoid 10
Activation function tanh 10
Activation function RelLU 11
batch 35
Increasing the size of computation
Summarizing experiments run for recognizing handwritten charts 36
Regularization
36
Adopting regularization to avoid overfitting
36
Understanding BatchNormalization
38
Playing
with Google Colab CPUs, GPUs, and TPUs 39
Sentiment analysis 42
and AutoML
Hyperparameter tuning
Predicting output
45
A practical overview of backpropagation 46
What have we learned so far? 48
Towards a deep learning approach 48
References 49
[w]-
Table of Contents
[v]
Table of Contents
269
Fine-tuning BERT 270
Classifying
with BERT command line 271
Using BERT as part of your own network 275
Summay 275
References
279
Networks
Chapter 8:RecurrentNeural 280
The basic RNN cell 283
time (BPTT)
Backpropagation through 284
Vanishing and exploding gradients 285
RNN cell variants 285
short-term memory (LSTM)
Long 288
Gated recurrent unit (GRU) 288
Peephole LSTM 289
RNN variants 289
Bidirectional RNNs 290
Stateful RNNs 291
RNN topologies
to text 292
learning generate
Example- One-to-Many 300
Example - Many-to-One Sentiment Analysis
307
Example- Many-to-Many - POS tagging
316
Encoder-Decoder architecture seq2seq
without attention for machine translation 318
Example-seq2seq 328
Attention mechanism
for machine translation 330
Example- seq2seq with attention
[vi] -
Table of Contents
Variational
Autoencoders 399
Summary 404
References 405
Chapter 11: Reinforcement Learning 407
Introduction 407
RL lingo 409
Deep reinforcement learning algorithms 411
Reinforcement success in recent years 414
Introduction to OpenAI Gym 415
Random agent playing Breakout 418
Deep Q-Networks 420
DQN for CartPole 422
DQN to play a game of Atari 427
DQN variants 430
Double DQN 430
Dueling DQN 431
Rainbow 434
Deep deterministic policy gradient 434
Summary 436
References 436
Chapter 12:TensorFlow and Cloud 439
Deep learning on cloud 439
Microsoft Azure 440
Amazon Web Services (AWS) 442
Google Cloud Platform (GCP) 444
BM Cloud 447
Virtual machines on cloud 447
EC2 on Amazon 448
Compute Instance on GCP 450
vil
Table of Contents
Virtual
machine on Microsoft Azure 451
Jupyter Notebooks on cloud 451
SageMaker 452
Google Colaboratoryy 452
Microsoft Azure Notebooks
TensorFlow Extended for production 455
TFX Pipelines
456
TFX pipeline components 457
TFX libraries 458
TensorFlow Enterprise 459
Summary 459
References 460
Chapter13: TensorFlow for Mobile and loT and TensorFlow.js 461
TensorFlow Mobile 461
TensorFlow Lite 462
Quantization 462
FlatBuffers 463
Mobile converter 463
Mobile optimized interpreter 463
Supported platforms 464
Architecture 464
TensorFlow Lite 464
Using
A generic example of application 465
Using GPUs and accelerators 466
An example of application 466
Pretrained models in TensorFlow Lite
468
Image classification 470
Object detection 471
Pose estimation 471
Smart reply 471
Segmentation 471
Style transfer 471
Text classification
472
Question and answering 472
A note about using mobile GPUs 473
An overview of federated learning at the edge 474
TensorFlow FLAPIs 476
TensorFlow.js 478
Vanilla
TensorFlow js 478
Converting models 485
Table of Contemts
[ix]
Table of Contents