O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deep Learning in the Browser

Book Description

This book covers the crossroads of web development and deep learning. Both technologies are beginning to meet, and this honeymoon will produce new fantastic applications that you cannot even imagine yet.

In this book you will see how to concretely use the main JavaScript deep learning frameworks and web programming in the browser with the capture of inputs and the WebGL implementation. Deep learning in the browser is currently at an embryonic stage, but this is the best time to bet on it before it becomes a giant, and this book will get you in on the action.

Are you ready to embark on the adventure?

Table of Contents

  1. Preface
    1. Book Example
  2. 1. Introduction to deep learning
    1. The math behind deep neural networks
      1. The Perceptron - gated linear regression
      2. The multi-layer Perceptron
      3. Convolution and pooling
      4. Activation functions
    2. Training deep neural networks
      1. The importance of the loss function
      2. Regularization
      3. The back-propagation algorithm
      4. Optimization methods
    3. Summary
  3. 2. Neural network architectures
    1. Convolutional Neural Network (CNN)
      1. AlexNet
      2. GoogLeNet
      3. ResNet
      4. SqueezeNet
    2. Recurrent neural network (RNN)
      1. LSTM
      2. GRU
    3. Deep reinforcement learning
      1. DQN
    4. Summary
  4. 3. Deep learning frameworks for JavaScript
    1. TensorFlow.js
      1. The TensorFlow.js playground
      2. The XOR problem
      3. Solving XOR
      4. The network architecture
      5. Tensors
      6. Operations
      7. Training
      8. The TensorFlow.js Ecosystem
    2. WebDNN
    3. Keras.js
    4. Summary
  5. 4. JavaScript Fundamentals for Deep Learning
    1. TypedArrays in JavaScript
      1. ArrayBuffer
      2. DataView
    2. Concurrency in JavaScript
      1. The JavaScript event loop
      2. Creating an asynchronous function with Promise
      3. Using the new async/await syntax
      4. Multi-threading using WebWorkers
      5. A processing loop for deep learning applications
    3. Loading resources on CPU/GPU
      1. Fetch API
      2. Label encoding
      3. One-hot Encoding
    4. Summary
  6. 5. GPU acceleration with WebGL
    1. Introduction to WebGL
      1. The WebGL workflow
      2. Fragment shader rendering
    2. General purpose computing with WebGL
      1. Debugging WebGL
      2. Render to texture
      3. Precision matters
      4. Optimizations
      5. Beware of floating-point specials
      6. From CPU to GPU and vice versa
    3. Texture and Shaders for Matrix Computation
      1. Standard matrix addition
      2. Standard matrix multiplication
      3. Activation function application
      4. Mastering WGLMatrix
    4. Application to handwritten digit recognition
      1. Data encoding
      2. Memory optimization
      3. Feedforward
      4. The first attempt
      5. Improving the performance
    5. Summary
  7. 6. Extracting data from the browser
    1. Loading image data
      1. Extracting pixels from an image
      2. Loading remote resources
      3. Fetching binary blobs
    2. Rendering pixel data to the screen
      1. Displaying images
      2. Rendering pixel data to canvas
      3. Interpolating image data
      4. Drawing shapes to canvas
    3. Accessing camera, microphone and speakers
      1. Capturing images from the Webcam
      2. Recording Audio from the Microphone
      3. Loading, decoding and playing sounds
    4. Utility tools in deep learning frameworks
      1. TensorFlow.js
      2. Keras.js
      3. WebDNN
    5. Summary
  8. 7. Recipes for advanced data manipulation
    1. Deserializing Protobuf
      1. Parsing Caffe model parameters
      2. Parsing Tensorflow graphs
      3. A note on floating point precision
    2. Drawing charts with Chart.js
      1. Exploring different chart types
      2. Configuring datasets
      3. Updating values
      4. Overview of options and configurations
    3. Drawing sketches using canvas
      1. Drawing on canvas
      2. Extracting pen strokes
    4. Compute a spectogram from the microphone
    5. Detecting and tracking faces
      1. Tracking faces with Jeeliz FaceFilter
      2. Tracking faces with Tracking.js
      3. Native support for face detection in Chrome
    6. Summary
  9. 8. Building applications with TensorFlow.js
    1. Gesture classification using TensorFlow.js
      1. The algorithm
      2. Setting up your TensorFlow.js project
      3. Instantiating the KNN Image Classifier
      4. The TensorFlow.js processing loop
      5. Wrap-up
    2. Text Generation using TensorFlow.js
      1. The algorithm
      2. The Keras model
      3. Converting a Keras model into a TensorFlow.js model
      4. Setting up our project
      5. Importing a Keras model in TensorFlow.js
      6. The TensorFlow.js processing loop
      7. Constructing the model input
      8. Performing a prediction
      9. Sampling our model output
      10. Wrap-up
    3. Denoising images using TensorFlow.js
      1. The algorithm
      2. Converting a Keras model into a TensorFlow.js model
      3. Setting up our project
      4. Initialization
      5. The application flow
      6. Loading a test digit
      7. Updating the noise
      8. Generating the distorted image
      9. Denoising the image
      10. The initialization function
      11. Wrap-up
    4. Summary
    5. Final conclusion