O'Reilly logo

Learning TensorFlow by Itay Lieder, Yehezkel S. Resheff, Tom Hope

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Go with the Flow: Up and Running with TensorFlow

In this chapter we start our journey with two working TensorFlow examples. The first (the traditional “hello world” program), while short and simple, includes many of the important elements we discuss in depth in later chapters. With the second, a first end-to-end machine learning model, you will embark on your journey toward state-of-the-art machine learning with TensorFlow.

Before getting started, we briefly walk through the installation of TensorFlow. In order to facilitate a quick and painless start, we install the CPU version only, and defer the GPU installation to later.1 (If you don’t know what this means, that’s OK for the time being!) If you already have TensorFlow installed, skip to the second section.

Installing TensorFlow

If you are using a clean Python installation (probably set up for the purpose of learning TensorFlow), you can get started with the simple pip installation:

$ pip install tensorflow

This approach does, however, have the drawback that TensorFlow will override existing packages and install specific versions to satisfy dependencies. If you are using this Python installation for other purposes as well, this will not do. One common way around this is to install TensorFlow in a virtual environment, managed by a utility called virtualenv.

Depending on your setup, you may or may not need to install virtualenv on your machine. To install virtualenv, type:

$ pip install virtualenv

See http://virtualenv.pypa.io ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required