2 TensorFlow essentials

 

This chapter covers

  • Understanding the TensorFlow workflow
  • Creating interactive notebooks with Jupyter
  • Visualizing algorithms by using TensorBoard

Before implementing machine-learning algorithms, let’s get familiar with how to use TensorFlow. You’re going to get your hands dirty writing simple code right away! This chapter covers some essential advantages of TensorFlow to convince you that it’s the machine-learning library of choice. Before you continue, follow the procedures in the appendix for step-by-step installation instructions, then return here.

As a thought experiment, let’s see what happens when we use Python code without a handy computing library. It’ll be like using a new smartphone without installing any additional apps. The functionality will be there, but you’d be much more productive if you had the right tools.

Suppose you’re a private business owner tracking the flow of sales for your products. Your inventory consists of 100 items, and you represent each item’s price in a vector called prices. Another 100-dimensional vector called amounts represents the inventory count of each item. You can write the chunk of Python code shown in listing 2.1 to calculate the revenue of selling all products. Keep in mind that this code doesn’t import any libraries.

Listing 2.1 Computing the inner product of two vectors without using a library

revenue = 0
for price, amount in zip(prices, amounts):
   revenue += price * amount

2.1 Ensuring that TensorFlow works

 
 
 

2.2 Representing tensors

 
 
 
 

2.3 Creating operators

 
 
 

2.4 Executing operators within sessions

 
 
 
 

2.5 Understanding code as a graph

 
 
 

2.5.1 Setting session configurations

 

2.6 Writing code in Jupyter

 
 
 

2.7 Using variables

 
 
 

2.8 Saving and loading variables

 
 
 

2.9 Visualizing data using TensorBoard

 
 
 

2.9.1 Implementing a moving average

 
 

2.9.2 Visualizing the moving average

 
 
 
 

2.10 Putting it all together: The TensorFlow system architecture and API

 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage