Deep Learning with JavaScript
Neural networks in TensorFlow.js
Shanqing Cai, Stanley Bileschi, Eric D. Nielsen with Francois Chollet
Foreword by Nikhil Thorat and Daniel Smilkov
  • January 2020
  • ISBN 9781617296178
  • 560 pages
  • printed in black & white

This book should serve as the authoritative source for readers who want to learn ML and use JavaScript as their main language.

From the Foreword by Nikhil Thorat and Daniel Smilkov, TensorFlow.js
Deep learning has transformed the fields of computer vision, image processing, and natural language applications. Thanks to TensorFlow.js, now JavaScript developers can build deep learning apps without relying on Python or R. Deep Learning with JavaScript shows developers how they can bring DL technology to the web. Written by the main authors of the TensorFlow library, this new book provides fascinating use cases and in-depth instruction for deep learning apps in JavaScript in your browser or on Node.

About the Technology

Running deep learning applications in the browser or on Node-based backends opens up exciting possibilities for smart web applications. With the TensorFlow.js library, you build and train deep learning models with JavaScript. Offering uncompromising production-quality scalability, modularity, and responsiveness, TensorFlow.js really shines for its portability. Its models run anywhere JavaScript runs, pushing ML farther up the application stack.

About the book

In Deep Learning with JavaScript, you’ll learn to use TensorFlow.js to build deep learning models that run directly in the browser. This fast-paced book, written by Google engineers, is practical, engaging, and easy to follow. Through diverse examples featuring text analysis, speech processing, image recognition, and self-learning game AI, you’ll master all the basics of deep learning and explore advanced concepts, like retraining existing models for transfer learning and image generation.
Table of Contents detailed table of contents

Part 1: Motivation and basic concepts

1 Deep Learning and JavaScript

1.1 Artificial intelligence, machine learning, neural networks, and deep learning

1.1.1 Artificial intelligence

1.1.2 Machine learning: How it differs from traditional programming

1.1.3 Neural networks and deep learning

1.1.4 Why deep learning? Why now?

1.2 Why combine JavaScript and machine learning?

1.2.1 Deep learning with Node.js

1.2.2 The JavaScript ecosystem

1.3 Why TensorFlow.js?

1.3.1 A brief history of TensorFlow, Keras, and TensorFlow.js

1.3.2 Why TensorFlow.js: A brief comparison with similar libraries

1.3.3 How is TensorFlow.js being used by the world?

1.3.4 What this book will and will not teach you about TensorFlow.js


Part 2: A gentle introduction to TensorFlow.js

2 Getting started: Simple linear regression in TensorFlow.js

2.1 Example 1: Predicting the duration of a download using TensorFlow.js

2.1.1 Project Overview : Duration Prediction

2.1.2 A note on code listings and console interactions

2.1.3 Creating and formatting the data

2.1.4 Defining a simple model

2.1.5 Fitting the model to the training data

2.1.6 Using our trained model to make predictions

2.1.7 Summary of our first example

2.2 Inside Dissecting gradient descent from example 1

2.2.1 The intuitions behind gradient descent optimization

2.2.2 Backpropagation: Inside gradient descent

2.3 Linear regression with multiple input features

2.3.1 The Boston Housing Prices dataset

2.3.2 Getting and running the Boston-housing project from GitHub

2.3.3 Accessing the Boston-housing data

2.3.4 Precisely defining the Boston-housing problem

2.3.5 A slight diversion into data normalization

2.3.6 Linear regression on the Boston-housing data

2.4 How to interpret your model

2.4.1 Extracting meaning from learned weights

2.4.2 Extracting internal weights from the model

2.4.3 Caveats on interpretability



3 Adding nonlinearity: Beyond weighted sums

3.1 Nonlinearity: What it is and what it is good for

3.1.1. Building the Intuition for Nonlinearity in Neural Networks

3.2 Nonlinearity at output: Models for classification

3.2.2. Measuring the Quality of Binary Classifiers: Precision, Recall, Accuracy, and ROC curves

3.2.4. Binary Cross Entropy: The Loss Function for Binary Classification

3.3 Multiclass classification

3.3.1. One-hot Encoding of Categorical Data

3.3.2. Softmax Activation

3.3.3. Categorical Cross Entropy: The Loss Function for Multi-class Classification

3.3.4. Confusion Matrix: Fine-grained Analysis of Multi-class Classification



4 Recognizing images and sounds using convnets

4.1 From vectors to tensors: Representing images

4.1.1. The MNIST Dataset

4.2 Your first convnet

4.2.1. conv2d Layer

4.2.2. maxPooling2d Layer

4.2.3. Repeating Motifs of Convolution and Pooling

4.2.4. Flatten and Dense Layers

4.2.5. Training the Convnet

4.2.6. Using Convnet to Make Predictions

4.3 Beyond browsers: Training models faster using Node.js

4.3.1. Dependencies and Imports for Using tfjs-node

4.3.2. Training an enhanced convnet for MNIST in tfjs-node

4.3.3. Saving Model from Node.js and Loading Model in Browser

4.4 Spoken-word recognition: Applying convnets on audio data

4.4.1 Spectrograms: Representing sounds as images



5 Transfer learning: Reusing pretrained neural networks

5.1 Introduction to transfer learning: Reusing pretrained models

5.1.1 Transfer learning based on compatible output shapes: Freezing layers

5.1.2 Transfer learning on incompatible output shapes: Creating a new model using outputs from the base model

5.1.3 Getting the most out of transfer-learning through fine-tuning: An audio example

5.2 Object detection through transfer learning on a convnet

5.2.1 A simple object detection problem based on synthesized scenes

5.2.2 Deep dive into simple object detection



Part 3: Advanced deep learning with TensorFlow.js

6 Working with data

6.1 Using to manage data

6.2 Training models with model.fitDataset

6.3 Common patterns for accessing data

6.3.1 Working with CSV format data

6.3.2 Accessing video data using

6.3.3 Accessing audio data using

6.4 Your data is likely flawed: Dealing with problems in your data

6.4.1 Theory of data

6.4.2 Detecting and cleaning problems with data

6.5 Data augmentation



7 Visualizing data and models

7.1 Data visualization

7.1.1 Visualizing data using tfjs-vis

7.1.2 An integrative case study: Visualizing weather data with tfjs-vis

7.2 Visualizing models after training

7.2.1 Visualizing the internal activations of a convent

7.2.2 Visualizing what convolutional layers are sensitive to: Maximally activating images

7.2.3 Visual interpretation of a convnet’s classification result

Materials for further reading and exploration



8 Underfitting, overfitting, and the universal workflow of machine learning

8.1 Formulation of the temperature-prediction problem

8.2 Underfitting, overfitting, and countermeasures

8.2.1 Underfitting

8.2.2 Overfitting

8.2.3 Reducing overfitting with weight regularization and visualizing it working

8.3 The universal workflow of machine learning



9 Deep learning fo r sequences and text

9.1 Second attempt at weather prediction: Introducing RNNs

9.1.1 Why dense layers fail to model sequential order

9.1.2 How RNNs model sequential order

9.2 Building deep-learning models for text

9.2.1 How text is represented in machine learning: One-hot and multi-hot encoding

9.2.2 First attempt at the sentiment-analysis problem

9.2.3 A more efficient representation of text: Word embeddings

9.2.4 1D convnets

9.3 Sequence-to-sequence tasks with attention mechanism

9.3.1 Formulation of the sequence-to-sequence task

9.3.2 The encoder-decoder architecture and the attention mechanism

9.3.3 Deep dive into the attention-based encoder-decoder model

Materials for further reading



10 Generative deep learning

10.1 Generating text with LSTM

10.1.1. Next-character predictor: A simple way to generate text

10.1.2. The LSTM-text-generation example

10.1.3. Temperature: adjustable randomness in the generated text

10.2 Variational autoencoders: Finding an efficient and structured vector representation of images

10.2.1 Classical autoencoder and VAE: Basic ideas

10.2.2 A detailed example of VAE: The Fashion-MNIST example

10.3 Image generation with GANs

10.3.1 The basic idea behind GANs

10.3.2 The building blocks of ACGAN

10.3.3 Diving deeper into the training of ACGAN

10.3.4 Seeing the MNIST ACGAN training and generation


Materials for further reading


11 Basics of deep reinforcement learning

11.1 The formulation of reinforcement-learning problems

11.2 Policy networks and policy gradients: The cart-pole example

11.2.1 Cart-pole as a reinforcement-learning problem

11.2.2 Policy network

11.2.3 Training the policy network: The REINFORCE algorithm

11.3 Value networks and Q-learning: The snake game example

11.3.1 Snake as a reinforcement-learning problem

11.3.2 Markov decision process and Q-values

11.3.3 Deep Q-Network

11.3.4 Training the deep Q-network

Materials for further reading



Part 4: Summary and closing words

12 Testing, optimizing, and deploying models

12.1 Testing TensorFlow.js models

12.1.1 Traditional unit testing

12.1.2 Testing with golden values

12.1.3 Considerations around continuous training

12.2 Model optimization

12.2.1 Model-size optimization through post-training weight quantization

12.2.2 Inference speed optimization using GraphModel conversion

12.3 Deploying TensorFlow.js models on various platforms and environments

12.3.1 Additional considerations when deploying to the web

12.3.2 Deployment to cloud serving

12.3.3 Deploying to a browser extension, like Chrome Extension

12.3.4 Deploying TensorFlow.js models in JavaScript-based mobile applications

12.3.5 Deploying TensorFlow.js models in JavaScript-based cross-platform desktop applications

12.3.6 Deploying TensorFlow.js models on WeChat and as other JavaScript-based mobile app plugin systems

12.3.7. Deploying TensorFlow.js models on single-board computers

12.3.8 Summary of deployments

Materials for further reading



13 Summary, conclusions, and beyond

13.1 Key concepts in review

13.1.1 Various approaches to AI

13.1.2 What makes deep learning stand out among the subfields of machine learning

13.1.3 How to think about deep learning at a high level

13.1.4 Key enabling technologies of deep learning

13.1.5 Applications and opportunities unlocked by deep learning in JavaScript

13.2 Quick overview of the deep-learning workflow and algorithms in TensorFlow.js

13.2.1 The universal workflow of supervised deep learning

13.2.2 Reviewing model and layer types in TensorFlow.js: A quick reference

13.2.3 Leveraging pre-trained models from TensorFlow.js

13.2.4 The space of possibilities

13.2.5 Limitations of deep learning

13.4 Pointers for further exploration

13.4.1 Practice real-world machine-learning problems on Kaggle

13.4.2 Read about the latest developments on arXiv

13.4.3 Explore the TensorFlow.js Ecosystem

Final words


Appendix A: Installing tfjs-node-gpu and its dependencies

A.1 Installing tfjs-node-gpu on Linux

A.2 Installing tfjs-node-gpu on Windows

Appendix B: A quick tutorial of tensors and operations in TensorFlow.js

B.1 Tensor creation and tensor axis conventions

B.1.1 Scalar (rank-0 tensor)

B.1.2 tensor1d (rank-1 tensor)

B.1.3 tensor2d (rank-2 tensor)

B.1.4 Rank-3 and higher-dimensional tensors

B.1.5 The notion of data batches

B.1.6 Real-world examples of tensors

B.1.7 Creating tensors from tensor buffers

B.1.8 Creating all-zero and all-one tensors

B.1.9 Creating randomly valued tensors

B.2 Basic tensor operations

B.2.1 Unary operations

B.2.2 Binary operations

B.2.3 Concatenation and slicing of tensors

B.3 Memory management in TensorFlow.js: tf.dispose() and tf.tidy()

B.4 Calculating gradients

What's inside

  • Image and language processing in the browser
  • Tuning ML models with client-side data
  • Text and image creation with generative deep learning
  • Source code samples to test and modify

About the reader

For JavaScript programmers interested in deep learning.

About the author

Shanging Cai, Stanley Bileschi and Eric D. Nielsen are software engineers with experience on the Google Brain team, and were crucial to the development of the high-level API of TensorFlow.js. This book is based in part on the classic, Deep Learning with Python by François Chollet.

placing your order...

Don't refresh or navigate away from the page.
print book $29.99 $49.99 pBook + eBook + liveBook
Additional shipping charges may apply
Deep Learning with JavaScript (print book) added to cart
continue shopping
go to cart

eBook $31.99 $39.99 3 formats + liveBook
Deep Learning with JavaScript (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.
customers also reading

This book 1-hop 2-hops 3-hops

FREE domestic shipping on three or more pBooks