If you’re looking to make a career move from programmer to AI specialist, this is the ideal place to start. Based on Laurence Moroney's extremely successful AI courses, this introductory book provides a hands-on, code-first approach to help you build confidence while you learn key topics.
You’ll understand how to implement the most common scenarios in machine learning, such as computer vision, natural language processing (NLP), and sequence modeling for web, mobile, cloud, and embedded runtimes. Most books on machine learning begin with a daunting amount of advanced math. This guide is built on practical lessons that let you work directly with the code.
You’ll learn:
• How to build models with TensorFlow using skills that employers desire
• The basics of machine learning by working with code samples
• How to implement computer vision, including feature detection in images
• How to use NLP to tokenize and sequence words and sentences
• Methods for embedding models in Android and iOS
• How to serve models over the web and in the cloud with TensorFlow Serving
Author(s): Laurence Moroney
Edition: 1
Publisher: O'Reilly Media
Year: 2020
Language: English
Commentary: Vector PDF
Pages: 390
City: Sebastopol, CA
Tags: Machine Learning; Neural Networks; Natural Language Processing; Computer Vision; Python; JavaScript; Convolutional Neural Networks; Recurrent Neural Networks; iOS; Transfer Learning; Text Generation; Sentiment Analysis; Keras; TensorFlow; Android; Long Short-Term Memory; Text Classification; Time Series Analysis; Federated Learning; Image Segmentation; TensorFlow Lite; TensorFlow Serving; Datasets; Data Ethics; TensorFlow.js
Copyright
Table of Contents
Foreword
Preface
Who Should Read This Book
Why I Wrote This Book
Navigating This Book
Technology You Need to Understand
Online Resources
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Part I. Building Models
Chapter 1. Introduction to TensorFlow
What Is Machine Learning?
Limitations of Traditional Programming
From Programming to Learning
What Is TensorFlow?
Using TensorFlow
Installing TensorFlow in Python
Using TensorFlow in PyCharm
Using TensorFlow in Google Colab
Getting Started with Machine Learning
Seeing What the Network Learned
Summary
Chapter 2. Introduction to Computer Vision
Recognizing Clothing Items
The Data: Fashion MNIST
Neurons for Vision
Designing the Neural Network
The Complete Code
Training the Neural Network
Exploring the Model Output
Training for Longer—Discovering Overfitting
Stopping Training
Summary
Chapter 3. Going Beyond the Basics: Detecting Features in Images
Convolutions
Pooling
Implementing Convolutional Neural Networks
Exploring the Convolutional Network
Building a CNN to Distinguish Between Horses and Humans
The Horses or Humans Dataset
The Keras ImageDataGenerator
CNN Architecture for Horses or Humans
Adding Validation to the Horses or Humans Dataset
Testing Horse or Human Images
Image Augmentation
Transfer Learning
Multiclass Classification
Dropout Regularization
Summary
Chapter 4. Using Public Datasets with TensorFlow Datasets
Getting Started with TFDS
Using TFDS with Keras Models
Loading Specific Versions
Using Mapping Functions for Augmentation
Using TensorFlow Addons
Using Custom Splits
Understanding TFRecord
The ETL Process for Managing Data in TensorFlow
Optimizing the Load Phase
Parallelizing ETL to Improve Training Performance
Summary
Chapter 5. Introduction to Natural Language Processing
Encoding Language into Numbers
Getting Started with Tokenization
Turning Sentences into Sequences
Removing Stopwords and Cleaning Text
Working with Real Data Sources
Getting Text from TensorFlow Datasets
Getting Text from CSV Files
Getting Text from JSON Files
Summary
Chapter 6. Making Sentiment Programmable Using Embeddings
Establishing Meaning from Words
A Simple Example: Positives and Negatives
Going a Little Deeper: Vectors
Embeddings in TensorFlow
Building a Sarcasm Detector Using Embeddings
Reducing Overfitting in Language Models
Using the Model to Classify a Sentence
Visualizing the Embeddings
Using Pretrained Embeddings from TensorFlow Hub
Summary
Chapter 7. Recurrent Neural Networks for Natural Language Processing
The Basis of Recurrence
Extending Recurrence for Language
Creating a Text Classifier with RNNs
Stacking LSTMs
Using Pretrained Embeddings with RNNs
Summary
Chapter 8. Using TensorFlow to Create Text
Turning Sequences into Input Sequences
Creating the Model
Generating Text
Predicting the Next Word
Compounding Predictions to Generate Text
Extending the Dataset
Changing the Model Architecture
Improving the Data
Character-Based Encoding
Summary
Chapter 9. Understanding Sequence and Time Series Data
Common Attributes of Time Series
Trend
Seasonality
Autocorrelation
Noise
Techniques for Predicting Time Series
Naive Prediction to Create a Baseline
Measuring Prediction Accuracy
Less Naive: Using Moving Average for Prediction
Improving the Moving Average Analysis
Summary
Chapter 10. Creating ML Models to Predict Sequences
Creating a Windowed Dataset
Creating a Windowed Version of the Time Series Dataset
Creating and Training a DNN to Fit the Sequence Data
Evaluating the Results of the DNN
Exploring the Overall Prediction
Tuning the Learning Rate
Exploring Hyperparameter Tuning with Keras Tuner
Summary
Chapter 11. Using Convolutional and Recurrent Methods for Sequence Models
Convolutions for Sequence Data
Coding Convolutions
Experimenting with the Conv1D Hyperparameters
Using NASA Weather Data
Reading GISS Data in Python
Using RNNs for Sequence Modeling
Exploring a Larger Dataset
Using Other Recurrent Methods
Using Dropout
Using Bidirectional RNNs
Summary
Part II. Using Models
Chapter 12. An Introduction to TensorFlow Lite
What Is TensorFlow Lite?
Walkthrough: Creating and Converting a Model to TensorFlow Lite
Step 1. Save the Model
Step 2. Convert and Save the Model
Step 3. Load the TFLite Model and Allocate Tensors
Step 4. Perform the Prediction
Walkthrough: Transfer Learning an Image Classifier and Converting to TensorFlow Lite
Step 1. Build and Save the Model
Step 2. Convert the Model to TensorFlow Lite
Step 3. Optimize the Model
Summary
Chapter 13. Using TensorFlow Lite in Android Apps
What Is Android Studio?
Creating Your First TensorFlow Lite Android App
Step 1. Create a New Android Project
Step 2. Edit Your Layout File
Step 3. Add the TensorFlow Lite Dependencies
Step 4. Add Your TensorFlow Lite Model
Step 5. Write the Activity Code to Use TensorFlow Lite for Inference
Moving Beyond “Hello World”—Processing Images
TensorFlow Lite Sample Apps
Summary
Chapter 14. Using TensorFlow Lite in iOS Apps
Creating Your First TensorFlow Lite App with Xcode
Step 1. Create a Basic iOS App
Step 2. Add TensorFlow Lite to Your Project
Step 3. Create the User Interface
Step 4. Add and Initialize the Model Inference Class
Step 5. Perform the Inference
Step 6. Add the Model to Your App
Step 7. Add the UI Logic
Moving Beyond “Hello World”—Processing Images
TensorFlow Lite Sample Apps
Summary
Chapter 15. An Introduction to TensorFlow.js
What Is TensorFlow.js?
Installing and Using the Brackets IDE
Building Your First TensorFlow.js Model
Creating an Iris Classifier
Summary
Chapter 16. Coding Techniques for Computer Vision in TensorFlow.js
JavaScript Considerations for TensorFlow Developers
Building a CNN in JavaScript
Using Callbacks for Visualization
Training with the MNIST Dataset
Running Inference on Images in TensorFlow.js
Summary
Chapter 17. Reusing and Converting Python Models to JavaScript
Converting Python-Based Models to JavaScript
Using the Converted Models
Using Preconverted JavaScript Models
Using the Toxicity Text Classifier
Using MobileNet for Image Classification in the Browser
Using PoseNet
Summary
Chapter 18. Transfer Learning in JavaScript
Transfer Learning from MobileNet
Step 1. Download MobileNet and Identify the Layers to Use
Step 2. Create Your Own Model Architecture with the Outputs from MobileNet as Its Input
Step 3. Gather and Format the Data
Step 4. Train the Model
Step 5. Run Inference with the Model
Transfer Learning from TensorFlow Hub
Using Models from TensorFlow.org
Summary
Chapter 19. Deployment with TensorFlow Serving
What Is TensorFlow Serving?
Installing TensorFlow Serving
Installing Using Docker
Installing Directly on Linux
Building and Serving a Model
Exploring Server Configuration
Summary
Chapter 20. AI Ethics, Fairness, and Privacy
Fairness in Programming
Fairness in Machine Learning
Tools for Fairness
The What-If Tool
Facets
Federated Learning
Step 1. Identify Available Devices for Training
Step 2. Identify Suitable Available Devices for Training
Step 3. Deploy a Trainable Model to Your Training Set
Step 4. Return the Results of the Training to the Server
Step 5. Deploy the New Master Model to the Clients
Secure Aggregation with Federated Learning
Federated Learning with TensorFlow Federated
Google’s AI Principles
Summary
Index
About the Author
Colophon