Chapter 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 first get familiarized 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 it’s the machine-learning library of choice.

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 so 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 the following listing 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

2.1. Ensuring that TensorFlow works

2.2. Representing tensors

2.3. Creating operators

2.4. Executing operators with sessions

2.5. Writing code in Jupyter

2.6. Using variables

2.7. Saving and loading variables

2.8. Visualizing data using TensorBoard

2.9. Summary

sitemap