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.
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 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