Learning TensorFlow.js - Book Review

Gant Cover

I was delighted to get an advance copy of Gant Laborde’s “Learning TensorFlow.js” from O’Reilly and privileged to have written the foreword.

Gant has done something special with this book. In just 300 pages, he takes you end-to-end, in-depth through everything you need to know from an introduction to AI, understanding tensors, using them in the browser, deploying them, and more.

It ends with a capstone project (what a great idea, I might have to steal it for my next book!), where you can use Machine Learning to convert an image into a set of dice, like this:

Gant Dice Sculpture

How much fun is that?

I love this book because it is for a different audience than the traditional ML one. It starts with a great introduction to AI and then tells you about TensorFlow.js and how you can use it to build Machine Learning apps. Then, the mystery of Tensors is cracked open, and Gant leads you through some detailed examples of how you can convert images into Tensors for training and inference.

It guides you through the three main ways to get a working model.

First, you can find an existing model from TensorFlow Hub, and in Chapter 5, Gant leads you through using the inception model in JavaScript. Inception isn’t any toy model, though – it is a Convolutional Neural Network designed for image analysis and object detection. It’s not that long ago that it was state-of-the-art in research. And now it’s available in JavaScript!

Or, you can create your model from scratch, and Gant takes you through the code for defining layers, with deep neural networks to help predict numeric data (such as the famous titanic dataset) or Convolutional Neural networks for image classification.

Finally, there’s Transfer Learning, which could be the most exciting method for most developers, where you have a hybrid of both of the previous methods. You can stand on the shoulders of giants by using parts of an existing model, like Inception, but catered for your own needs.

When I started my Machine Learning journey, one frustration I had was that there was lots of material for creating models but relatively little for using them. The tutorial would end with a validation set showing how accurate the model was, and then it would move on to the next thing! I am delighted to say that this book does not fall into that pattern! So, if you want to build a browser-based app that uses a model, you’ll get lots of code showing you how!

For example, Chapter 6 shows you how to use the webcam in the browser, capturing frames and passing them to a model for classification. Chapter 10 shows you how to create a basic sketchpad for drawing images that a model can interpret.

Whether you’re an experienced Machine Learning expert, looking to see how to apply JavaScript to help solve your problems, or a JavaScript developer who wants to enter the wonderful world of ML, this book is for you. Check it out!