Skip to main content

TensorFlow For Dummies

E-Book

$22.99

TensorFlow For Dummies

Matthew Scarpino

ISBN: 978-1-119-46620-8 March 2018 368 Pages

E-Book
$22.99
E-Book
$22.99
Paperback
$34.99
Download Product Flyer

Download Product Flyer

Download Product Flyer is to download PDF in new tab. This is a dummy description. Download Product Flyer is to download PDF in new tab. This is a dummy description. Download Product Flyer is to download PDF in new tab. This is a dummy description. Download Product Flyer is to download PDF in new tab. This is a dummy description.

Description

Become a machine learning pro! 

Google TensorFlow has become the darling of financial firms and research organizations, but the technology can be intimidating and the learning curve is steep. Luckily, TensorFlow For Dummies is here to offer you a friendly, easy-to-follow book on the subject. Inside, you’ll find out how to write applications with TensorFlow, while also grasping the concepts underlying machine learning—all without ever losing your cool!

Machine learning has become ubiquitous in modern society, and its applications include language translation, robotics, handwriting analysis, financial prediction, and image recognition. TensorFlow is Google's preeminent toolset for machine learning, and this hands-on guide makes it easy to understand, even for those without a background in artificial intelligence. 

  • Install TensorFlow on your computer
  • Learn the fundamentals of statistical regression and neural networks
  • Visualize the machine learning process with TensorBoard
  • Perform image recognition with convolutional neural networks (CNNs)
  • Analyze sequential data with recurrent neural networks (RNNs)
  • Execute TensorFlow on mobile devices and the Google Cloud Platform (GCP)

If you’re a manager or software developer looking to use TensorFlow for machine learning, this is the book you’ll want to have close by.

Introduction 1

About This Book 1

Foolish Assumptions 2

Icons Used in This Book 2

Beyond the Book 3

Where to Go from Here 4

Part 1: Getting to Know Tensorflow 5

Chapter 1: Introducing Machine Learning with TensorFlow 7

Understanding Machine Learning 7

The Development of Machine Learning 8

Statistical regression 9

Reverse engineering the brain 10

Steady progress 11

The computing revolution 12

The rise of big data and deep learning 12

Machine Learning Frameworks 13

Torch 14

Theano 14

Caffe 14

Keras 15

TensorFlow 15

Chapter 2: Getting Your Feet Wet 17

Installing TensorFlow 17

Python and pip/pip3 18

Installing on Mac OS 19

Installing on Linux 20

Installing on Windows 20

Exploring the TensorFlow Installation 21

Running Your First Application 22

Exploring the example code 23

Launching Hello TensorFlow! 23

Setting the Style 24

Chapter 3: Creating Tensors and Operations 27

Creating Tensors 27

Creating Tensors with Known Values 28

The constant function 30

zeros, ones, and fill 30

Creating sequences 31

Creating Tensors with Random Values 31

Transforming Tensors.33

Creating Operations 35

Basic math operations 35

Rounding and comparison 37

Exponents and logarithms 38

Vector and matrix operations 39

Putting Theory into Practice 42

Chapter 4: Executing Graphs in Sessions 45

Forming Graphs 46

Accessing graph data 47

Creating GraphDefs 49

Creating and Running Sessions 51

Creating sessions 51

Executing a session 52

Interactive sessions 53

Writing Messages to the Log 54

Visualizing Data with TensorBoard 56

Running TensorBoard 57

Generating summary data 57

Creating custom summaries 59

Writing summary data 59

Putting Theory into Practice 62

Chapter 5: Training 65

Training in TensorFlow 66

Formulating the Model 66

Looking at Variables 67

Creating variables 68

Initializing variables 68

Determining Loss 69

Minimizing Loss with Optimization 70

The Optimizer class 70

The GradientDescentOptimizer 71

The MomentumOptimizer 75

The AdagradOptimizer 76

The AdamOptimizer 77

Feeding Data into a Session 78

Creating placeholders 79

Defining the feed dictionary 79

Stochasticity 80

Monitoring Steps, Global Steps, and Epochs 80

Saving and Restoring Variables 82

Saving variables 82

Restoring variables 83

Working with SavedModels 84

Saving a SavedModel 85

Loading a SavedModel 86

Putting Theory into Practice 86

Visualizing the Training Process 89

Session Hooks 90

Creating a session hook 91

Creating a MonitoredSession 93

Putting theory into practice 94

Part 2: Implementing Machine Learning 97

Chapter 6: Analyzing Data with Statistical Regression 99

Analyzing Systems Using Regression 100

Linear Regression: Fitting Lines to Data 100

Polynomial Regression: Fitting Polynomials to Data 103

Binary Logistic Regression: Classifying Data into Two Categories 105

Setting up the problem 105

Defining models with the logistic function 106

Computing loss with maximum likelihood estimation 107

Putting theory into practice 108

Multinomial Logistic Regression: Classifying Data into Multiple Categories 110

The Modified National Institute of Science and Technology (MNIST) Dataset 110

Defining the model with the softmax function 113

Computing loss with cross entropy 114

Putting theory into practice 115

Chapter 7: Introducing Neural Networks and Deep Learning 117

From Neurons to Perceptrons 117

Neurons 118

Perceptrons 119

Improving the Model 121

Weights 121

Bias 122

Activation functions 123

Layers and Deep Learning 127

Layers 128

Deep learning 129

Training with Backpropagation 129

Implementing Deep Learning 131

Tuning the Neural Network 133

Input standardization 134

Weight initialization 135

Batch normalization 136

Regularization 139

Managing Variables with Scope 141

Variable scope 141

Retrieving variables from collections 142

Scopes for names and arguments 143

Improving the Deep Learning Process 143

Creating tuned layers 144

Putting theory into practice 145

Chapter 8: Classifying Images with Convolutional Neural Networks (CNNs) 149

Filtering Images 149

Convolution 150

Averaging Filter 151

Filters and features 152

Feature detection analogy 153

Setting convolution parameters 153

Convolutional Neural Networks (CNNs) 155

Creating convolution layers 156

Creating pooling layers 158

Putting Theory into Practice 160

Processing CIFAR images 160

Classifying CIFAR images in code 162

Performing Image Operations 166

Converting images 166

Color processing 169

Rotating and mirroring 170

Resizing and cropping 172

Convolution 174

Putting Theory into Practice 175

Chapter 9: Analyzing Sequential Data with Recurrent Neural Networks (RNNs) 179

Recurrent Neural Networks (RNNs) 180

RNNs and recursive functions 181

Training RNNs 182

Creating RNN Cells 183

Creating a basic RNN 185

Predicting text with RNNs 188

Creating multilayered cells 190

Creating dynamic RNNs 191

Long Short-Term Memory (LSTM) Cells 192

Creating LSTMs in code 194

Predicting text with LSTMs 196

Gated Recurrent Units (GRUs) 196

Creating GRUs in code 197

Predicting text with GRUs 198

Part 3: Simplifying and Accelerating Tensorflow 199

Chapter 10: Accessing Data with Datasets and Iterators 201

Datasets 201

Creating datasets 202

Processing datasets 208

Iterators 213

One-shot iterators 213

Initializable iterators 215

Reinitializable iterators 216

Feedable iterators 217

Putting Theory into Practice 218

Bizarro Datasets 221

Loading data from CSV files 222

Loading the Iris and Boston datasets 223

Chapter 11: Using Threads, Devices, and Clusters 225

Executing with Multiple Threads 226

Configuring a new session 226

Configuring a running session 228

Configuring Devices 229

Building TensorFlow from source 229

Assigning operations to devices 235

Configuring GPU usage 237

Executing TensorFlow in a Cluster 238

Creating a ClusterSpec 239

Creating a server 240

Specifying jobs and tasks 241

Running a simple cluster 244

Chapter 12: Developing Applications with Estimators 247

Introducing Estimators 248

Training an Estimator 248

Testing an Estimator 250

Running an Estimator 250

Creating Input Functions 251

Configuring an Estimator 252

Using Feature Columns 253

Creating and Using Estimators 256

Linear regressors 257

DNN classifiers 260

Combined linear-DNN classifiers 262

Wide and deep learning 263

Analyzing census data 264

Running Estimators in a Cluster 269

Accessing Experiments 270

Creating an experiment 271

Methods of the experiment class 272

Running an experiment 273

Putting theory into practice 274

Chapter 13: Running Applications on the Google Cloud Platform (GCP) 277

Overview 278

Working with GCP projects 278

Creating a new project 279

Billing 279

Accessing the machine learning engine 280

The Cloud Software Development Kit (SDK) 280

The gcloud Utility 281

Google Cloud Storage 283

Buckets 283

Objects and virtual hierarchy 285

The gsutil utility 286

Preparing for Deployment 290

Receiving arguments 290

Packaging TensorFlow code 291

Executing Applications with the Cloud SDK 293

Local execution 294

Deploying to the cloud 295

Configuring a Cluster in the Cloud 299

Setting the training input 300

Obtaining the training output 303

Setting the prediction input 304

Obtaining the prediction output 305

Part 4: The Part of Tens 307

Chapter 14: The Ten Most Important Classes 309

Tensor 309

Operation 310

Graph 310

Session 311

Variable 311

Optimizer 312

Estimator 312

Dataset 312

Iterator 313

Saver 313

Chapter 15: Ten Recommendations for Training Neural Networks 315

Select a Representative Dataset 315

Standardize Your Data 316

Use Proper Weight Initialization 316

Start with a Small Number of Layers 316

Add Dropout Layers 317

Train with Small, Random Batches 317

Normalize Batch Data 317

Try Different Optimization Algorithms 318

Set the Right Learning Rate 318

Check Weights and Gradients 318

Index 319

ChapterPageDetailsDatePrint Run
1Many InstancesErrata in text
Chapter 1 at several places in the text and in the picture with the timeline:

Currently Reads: LeCunn

Should Read: Yann LeCun
25-Jun-18

339Errata in text
Chapter 3, P 39 at the top of the book in the table:

Currently Reads: Returns elements of the first tensor raised to the power of the elements of the second vector

Should Read: Returns elements of the first tensor raised to the power of the elements of the second tensor
25-Jun-18

452Errata in text
Chapter 4, P 52 above in the first paragraph there are two references to other chapters. The sentence with the second reference to Chapter 10 should be Chapter 11.
25-Jun-18

463Errata in text
Chapter 4 P 63, at the very bottom of the last line of the program example a closing parenthesis is missing. Please include it.
25-Jun-18

8156Errata in text
The third last paragraph currently reads:
An RGB image has three channels, so its tensor will have three channels.

Should read:
An RGB image has three channels, so its tensor will have three matrices.
27-Jun-18

8160Errata in text
Please change the given pool_size value in the second paragraph from [2, 2] to [3, 2].
27-Jun-18

8167Errata in text
Chapter 8 P 167, Error in the table.

Currently Reads:
PNG encoding

Should Read:
JPEG encoding
25-Jun-18

9184Errata in text
Chapter 9 P 184,In table 9-1:

Currently Reads:
seven properties

Should Read:
eight properties
25-Jun-18

9193Errata in text
The last paragraph should be moved to the end of the gray box at the top of the page.
27-Jun-18

10211Errata in text
Chapter 10 P 211, Table 10-4:

Currently Reads:
five routines

Should Read:
four routines
25-Jun-18