TensorFlow for beginners. Part 1: general information, installing the library

Original author: Chidume Nnamdi
  • Transfer
  • Tutorial
TensorFlow is an open source library created by Google, which is used to develop systems using machine learning technology. This library includes the implementation of many powerful algorithms designed to solve common machine learning problems, including pattern recognition and decision making. This material is dedicated to the basics of TensorFlow and is designed for readers who do not know anything about this library.

image



TensorFlow: A Modern Machine Learning Library


The TensorFlow project was transferred by Google to the category of open-source in 2015. His predecessor was the DistBelief project, the years of experience accumulated during the work with which were reflected in TensorFlow.

The developers of the TensorFlow library sought to be flexible, efficient, extensible, portable. As a result, it can be used in a variety of computing environments - from those that are formed by mobile devices, to environments represented by huge clusters. The library allows you to quickly prepare trained models for real work, which eliminates the need to create special model implementations for production purposes.

The TensorFlow library, on the one hand, attracts the attention of the open source community and is open to innovation, and on the other hand, enjoys the support of a large corporation. This allows us to say that she has every chance of stable development.

This library, thanks to the joint efforts of all those who work on it, is suitable for solving problems of various scales. From those that arise in front of an independent developer, to those that confront startups and even large companies like Google. From the moment this library became open source, since November 2015, it has become one of the most interesting machine learning libraries. It is increasingly used in research, in the development of real applications, in training.

TensorFlow is constantly improving, it is constantly supplied with something new, optimized. In addition, a community has been growing around this library.

About TensorFlow


Tensor is a standard way of representing data in deep learning systems. Tensors are multidimensional arrays, an extension of two-dimensional tables (matrices) for representing data with higher dimensions. Simply put, a tensor is an n-dimensional matrix.

In general, if you are used to working with matrices, tensors can be imagined in the same way as you imagine matrices.

Let's start by installing TensorFlow.

Install TensorFlow


If you are starting out with a clean Python installation (you might have installed Python specifically for learning TensorFlow), to install TensorFlow just use pip:

pip install tensorflow

This approach is simple, but it has some unpleasant features. They consist in the fact that when installing TensorFlow, instead of already installed packages, certain versions of the dependency packages of this library will be installed.

If you are using an existing Python installation for other purposes, this method is not recommended. One way to install TensorFlow bypassing the above features is to use a virtual environment controlled by the utility virtualenv. Perhaps you already have this utility installed, maybe not. If you don’t have it installed, you can install it like this:

pip install virtualenv

Here you can find details about virtualenv.

In order to install TensorFlow in a virtual environment, you first need to create such an environment. We are going to place it in a folder ~/envs, but you can choose another folder that is more suitable for you:

cd ~
mkdir envs
virtualenv ~/envs/tensorflow

Above, we created a virtual environment tensorflowin a folder ~/envs(it is represented by a folder ~/envs/tensorflow). In order to activate this environment, use the following command:

source ~/envs/tensorflow/bin/activate

After that, the command line prompt should change, indicating the activated virtual environment:

(tensorflow)

Now you can install TensorFlow in a virtual environment using pip:

(tensorflow) pip install tensorflow

Such an installation will not affect other packages installed on the computer.

To exit the virtual environment, you can use the following command:

(tensorflow) deactivate

After that, the command prompt will take its normal form.

Until recently, TensorFlow was very difficult to use in a Windows environment. However, after the release of TensorFlow 0.12, special problems in this area are no longer observed. Namely, to install the CPU version of TensorFlow for Windows, it is enough to run the following command:

pip install tensorflow

And to install the GPU version - the following:

pip install tensorflow-gpu

When installing this version of TensorFlow, it is assumed that you already have CUDA 8.

Now the TensorFlow library is installed on your computer, which means it's time to work with it. Let's start, as is usually the case when learning new technologies, with “Hello World!”

Dear readers! This material is a translation of the beginning of this TensorFlow Fundamentals publication. Do you think it's worth translating it further?

Only registered users can participate in the survey. Please come in.

Do you think it's worth moving the basics of TensorFlow further?

  • 92.5% Yes 223
  • 5.8% No 14
  • 1.6% Don't know 4

Also popular now: