Given the demand for AI and the ubiquity of JavaScript, TensorFlow.js was inevitable. With this Google framework, seasoned AI veterans and web developers alike can help propel the future of AI-driven websites. In this guide, author Gant Laborde (Google Developer Expert in machine learning and the web) provides a hands-on end-to-end approach to TensorFlow.js fundamentals for a broad technical audience that includes data scientists, engineers, web developers, students, and researchers.
You'll begin by working through some basic examples in TensorFlow.js before diving deeper into neural network architectures, DataFrames, TensorFlow Hub, model conversion, transfer learning, and more. Once you finish this book, you'll know how to build and deploy production-readydeep learning systems with TensorFlow.js.
• Explore tensors, the most fundamental structure of machine learning
• Convert data into tensors and back with a real-world example
• Combine AI with the web using TensorFlow.js
• Use resources to convert, train, and manage machine learning data
• Build and train your own training models from scratch
Author(s): Gant Laborde
Edition: 1
Publisher: O'Reilly Media
Year: 2021
Language: English
Commentary: Vector PDF
Pages: 340
City: Sebastopol, CA
Tags: Machine Learning; Deep Learning; JavaScript; Convolutional Neural Networks; Classification; Transfer Learning; Web Applications; TensorFlow; Image Classification; Tensor Calculus; Model Training; TensorFlow.js
Copyright
Table of Contents
Foreword
Preface
Let’s Do This
Why TensorFlow.js?
Who Should Read This Book?
Book Overview
The Chapters
The Takeaway
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Chapter 1. AI Is Magic
The Path of AI in JavaScript
What Is Intelligence?
The History of AI
The Neural Network
Today’s AI
Why TensorFlow.js?
Significant Support
Online Ready
Offline Ready
Privacy
Diversity
Types of Machine Learning
Quick Definition: Supervised Learning
Quick Definition: Unsupervised Learning
Quick Definition: Semisupervised Learning
Quick Definition: Reinforcement Learning
Information Overload
AI Is Everywhere
A Tour of What Frameworks Provide
What Is a Model?
In This Book
Associated Code
Chapter Sections
Common AI/ML Terminology
Chapter Review
Review Questions
Chapter 2. Introducing TensorFlow.js
Hello, TensorFlow.js
Leveraging TensorFlow.js
Let’s Get TensorFlow.js Ready
Getting Set Up with TensorFlow.js in the Browser
Using NPM
Including a Script Tag
Getting Set Up with TensorFlow.js Node
Verifying TensorFlow.js Is Working
Download and Run These Examples
Let’s Use Some Real TensorFlow.js
The Toxicity Classifier
Loading the Model
Classifying
Try It Yourself
Chapter Review
Chapter Challenge: Truck Alert!
Review Questions
Chapter 3. Introducing Tensors
Why Tensors?
Hello, Tensors
Creating Tensors
Tensors for Data Exercises
Tensors on Tour
Tensors Provide Speed
Tensors Provide Direct Access
Tensors Batch Data
Tensors in Memory
Deallocating Tensors
Automatic Tensor Cleanup
Tensors Come Home
Retrieving Tensor Data
Tensor Manipulation
Tensors and Mathematics
Recommending Tensors
Chapter Review
Chapter Challenge: What Makes You So Special?
Review Questions
Chapter 4. Image Tensors
Visual Tensors
Quick Image Tensors
JPGs and PNGs and GIFs, Oh My!
Browser: Tensor to Image
Browser: Image to Tensor
Node: Tensor to Image
Node: Image to Tensor
Common Image Modifications
Mirroring Image Tensors
Resizing Image Tensors
Cropping Image Tensors
New Image Tools
Chapter Review
Chapter Challenge: Sorting Chaos
Review Questions
Chapter 5. Introducing Models
Loading Models
Loading Models Via Public URL
Loading Models from Other Locations
Our First Consumed Model
Loading, Encoding, and Asking a Model
Interpreting the Results
Cleaning the Board After
Our First TensorFlow Hub Model
Exploring TFHub
Wiring Up Inception v3
Our First Overlayed Model
The Localization Model
Labeling the Detection
Chapter Review
Chapter Challenge: Cute Faces
Review Questions
Chapter 6. Advanced Models and UI
MobileNet Again
SSD MobileNet
Bounding Outputs
Reading Model Outputs
Displaying All Outputs
Detection Cleanup
Quality Checking
IoUs and NMS
Adding Text Overlays
Solving Low Contrast
Solving Draw Order
Connecting to a Webcam
Moving from Image to Video
Activating a Webcam
Drawing Detections
Chapter Review
Chapter Challenge: Top Detective
Review Questions
Chapter 7. Model-Making Resources
Out-of-Network Model Shopping
Model Zoos
Converting Models
Your First Customized Model
Meet Teachable Machine
Use Teachable Machine
Gathering Data and Training
Verifying the Model
Machine Learning Gotchas
Small Amounts of Data
Poor Data
Data Bias
Overfitting
Underfitting
Datasets Shopping
The Popular Datasets
Chapter Review
Chapter Challenge: R.I.P. You Will Be MNIST
Review Questions
Chapter 8. Training Models
Training 101
Data Prep
Design a Model
Identify Learning Metrics
Task the Model with Training
Put It All Together
Nonlinear Training 101
Gathering the Data
Adding Activations to Neurons
Watching Training
Improving Training
Chapter Review
Chapter Challenge: The Model Architect
Review Questions
Chapter 9. Classification Models and Data Analysis
Classification Models
The Titanic
Titanic Dataset
Danfo.js
Preparing for the Titanic
Training on Titanic Data
Feature Engineering
Dnotebook
Titanic Visuals
Creating Features (aka Preprocessing)
Feature Engineered Training Results
Reviewing Results
Chapter Review
Chapter Challenge: Ship Happens
Review Questions
Chapter 10. Image Training
Understanding Convolutions
Convolutions Quick Summary
Adding Convolution Layers
Understanding Max Pooling
Max Pooling Quick Summary
Adding Max Pooling Layers
Training Image Classification
Handling Image Data
The Sorting Hat
Getting Started
Converting Folders of Images
The CNN Model
Training and Saving
Testing the Model
Building a Sketchpad
Reading the Sketchpad
Chapter Review
Chapter Challenge: Saving the Magic
Review Questions
Chapter 11. Transfer Learning
How Does Transfer Learning Work?
Transfer Learning Neural Networks
Easy MobileNet Transfer Learning
TensorFlow Hub Check, Mate!
Utilizing Layers Models for Transfer Learning
Shaving Layers on MobileNet
Layers Feature Model
A Unified Model
No Training Needed
Easy KNN: Bunnies Versus Sports Cars
Chapter Review
Chapter Challenge: Warp-Speed Learning
Review Questions
Chapter 12. Dicify: Capstone Project
A Dicey Challenge
The Plan
The Data
The Training
The Website
Generating Training Data
Training
The Site Interface
Cut into Dice
Reconstruct the Image
Chapter Review
Chapter Challenge: Easy as 01, 10, 11
Review Questions
Afterword
Social
More Books
Other Options
More TensorFlow.js Code
Thanks
Appendix A. Chapter Review Answers
Chapter 1: AI Is Magic
Chapter 2: Introducing TensorFlow.js
Chapter 3: Introducing Tensors
Chapter 4: Image Tensors
Chapter 5: Introducing Models
Chapter 6: Advanced Models and UI
Chapter 7: Model-Making Resources
Chapter 8: Training Models
Chapter 9: Classification Models and Data Analysis
Chapter 10: Image Training
Chapter 11: Transfer Learning
Chapter 12: Dicify: Capstone Project
Appendix B. Chapter Challenge Answers
Chapter 2: Truck Alert!
Chapter 3: What Makes You So Special?
Chapter 4: Sorting Chaos
Chapter 5: Cute Faces
Chapter 6: Top Detective
Chapter 7: R.I.P. You will be MNIST
Chapter 8: The Model Architect
Chapter 9: Ship Happens
Chapter 10: Saving the Magic
Chapter 11: Warp-Speed Learning
Chapter 12: Easy as 01, 10, 11
Appendix C. Rights and Licenses
Unsplash License
Apache License 2.0
Public Domain
WTFPL
Creative Commons Attribution-sharealike 4.0 International License (CC BY-SA 4.0)
Creative Commons Attribution 4.0 International License (CC BY 4.0)
Gant Laborde and O’Reilly
TensorFlow and TensorFlow.js Logos
Index
About the Author
Colophon