Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial! Help you to complete the hardest from 0 to 1

If you encounter problems with the installation, please leave a message at the end of the article.

Yuedong Intelligent Public Account: aibbtcom

The concept of AI seems to have suddenly become popular. At the beginning of the year, AlphaGo, which defeated Li Shishi by a large score, successfully attracted a lot of attention, but in fact, look at the voice assistant on your mobile phone , the face recognition on the camera , and today's headlines help you automatically. The filtered news, as well as the "daily recommendations" of songs from major music software... All kinds of AI have already entered all aspects of our lives . It has profoundly affected us. It can be said that this is an era of AI.

In fact, as early as the end of last year, Google open sourced its deep learning system Tensorflow used to make AlphaGo. I believe that many students have been eager to move towards this powerful machine learning system, but although there are actually many tutorials about Tensorflow , even Google The official gave a detailed tutorial on Tensorflow's official website, and some websites have translated it into Chinese (click to view) , but it still has thresholds, especially for those who don't know much about computers

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

What I want to do today is to cross this hurdle with all these students who have almost no programming foundation but want to learn Tensorflow. Tell you all what you need to do to get ready to program with Tensorflow, and how to understand what the code on the tutorial means, so without further ado, let's get started.

Installation under Linux operating system

Installation Environment

There is no Windows in Tensorflow's support list. Although Docker can be used to run on Windows, there are many small problems. The best supported system is based on the unix kernel, such as Linux, so we'd better install a Linux environment to run it. Linux is a free and open source operating system with a wide range of applications. For example, the well-known Android is an improved operating system for mobile phones based on Linux . For us, the most easy-to-understand version is the famous Ubuntu, which can be downloaded from the official website by clicking the link. As mentioned earlier, it is free to download and use.

If you are using a Mac, it is a lot more convenient, because Mac os itself is a Unix-based operating system, and it already has all the components needed to install Tensorflow. Therefore, many steps of the installation can be omitted and the installation of Tensorflow can be performed directly, but the commands are different from those of Ubuntu. But you can also take a look at the following tutorials, it will also be helpful to understand those commands. Uh...you said you installed Windows on your Mac?

After downloading, you will get an .iso file with the Ubuntu system installed. There are two ways to deal with it, one is to install it directly, and form a dual system with the system that the computer is currently using (of course, you can also replace the current system, but I think no one will be willing to do that haha). If you don't want to go all out, you can also virtualize a system through a virtual machine. However, installing a virtual machine has certain requirements on configuration, after all, it is equivalent to opening two systems on your computer at the same time - the CPU should preferably not be lower than the 4th generation i3 (especially notebooks, i3/5/7 CPU models The first x in the four digits of -xxxx represents its algebra). Memory - Note that the memory must not be less than 4g, because the memory you allocate to the virtual machine will be drawn 1:1 from your physical memory after the virtual machine is started. Plus the consumption of the physical machine system. Of course, this configuration table has only a lower limit and no upper limit. The better your computer configuration, the better the experience. If you install dual systems, the requirements for configuration are much smaller.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

virtual machine installation

There are many related tutorials on the Internet, so I won’t repeat them here. Note that when searching and installing dual-system tutorials, add the version number of the system you are using and the Ubuntu system you downloaded. Here are just a few points to note.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Because Linux attaches great importance to security , not only the rights management is very strict, but also requires you to enter a password when creating an operating system, which will be used to log in and gain root privileges. Just like the above interface, if you don't fill in all the blanks, you can't click the next step.

Python

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

The appearance of the Ubuntu desktop, (quietly, I think that Unix-based systems are generally much better looking than Windows, mainly because the fonts look really comfortable)

After installation, we saw some familiar software and some unfamiliar software, let's ignore it and introduce Python. Python is a high-level language. Its characteristics are that the program is very concise, but because of its simplicity, when it is translated into instructions that the CPU can understand - that is, the speed of executing code will be lower than those of lower-level languages, such as C language. Slow down. However, in the face of current computer performance, most of the time, this speed difference is not worth mentioning.

interpreter

Many people may think that Python is very abstract, because when it comes to Python, people will not immediately think that it has a dedicated compiler like C language. There are all kinds of weird places Python can execute. It can even be easily executed directly in the system's Terminal (a tool similar to the command line in Windows). Ubuntu comes with Python, so generally you don't have to worry about installing it.

Tensorflow supports a variety of front-end languages, but the support for Python is the best, so our tutorial is also based on Python . First, we open Terminal. As a very important part of Ubuntu, there are many ways to open it. such as right-clicking on the desktop

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

You can also click the Ubuntu icon in the upper left corner to search. After opening, you can see the Terminal window as shown below. Before the @ sign in the title bar is your username.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

If you 've never left the GUI (the one with a mouse and lots of icons for you to click) in your computer Don't panic when you see this frighteningly simple window, just type the correct command.

Before the official start I want to say: Be sure to pay attention to the prompts (in English) given by the window. In actual operation, various problems may be encountered, but the common problems can actually be found according to its error information. Just search for the corresponding information on the Internet and it can be solved, or even it will solve it by itself 's suggestion . If you find that your steps are correct, but it just doesn't work, just try a few more times, after all these services are provided by Google, and Google... you know.

Essential python-pip and python-dev

Enter the command in this window:

$ sudo apt-get install python-pip python-dev

Note that there is already a $ symbol in the window, so you don't actually need to include this $ symbol when copying or entering commands, but online tutorials generally include this symbol when giving commands, as a logo. Just pay attention.

The sudo at the beginning of the command means that this command will be executed with root privileges, so you need to enter the password you set at the beginning. Note that the input process will not be reflected on the screen . Just hit enter when you're done.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

After entering, a string of codes will appear, and then ask whether to continue, enter y and press Enter

Then you can wait for the installation to complete and explain the command: apt-get is a command to get software from a software repository, and a software repository is a common feature of all major Linux distributions: it is a series of servers or websites that store software , contains software packages and index files, users can easily use commands to automatically locate and install the software in it, and save the trouble of searching everywhere. install is the installation instruction, and python-pip and python-dev are the names of the two packages that need to be installed. Pip can be understood as a relatively advanced software installer, which is used to install Tensorflow, while dev is an additional class library, which is also required for the installation and operation of Tensorflow. If all goes well, we will see the following interface after the large string of English is drawn:

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

At this point, you can install Tensorflow. The instructions are as follows:

$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

As mentioned earlier, you may encounter such and such problems, such as the following picture

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

In these moments, don't panic, read the error message carefully, the further back is usually the more important, because conclusions are given at the end, like this one:

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

You see, it tells you not only what to try, but how to do it. Just do what it says

But in fact, the author did not use version 8.1.1 at that time. After using the upgrade command, I just upgraded to version 8.1.1. Enter the same command again, and it will tell you that your version is the latest. But the problem was indeed solved, and the prompt did not reappear after that.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Updater updated the version to 8.1.1, then this prompt will not bother you anymore

Enter the command to install Tensorflow again. If it doesn't work, try a few more times.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

If you look closely at the information in yellow letters, you will find the words Network is unreachable. If you have any legendary weapon, now is the time to use it. But it doesn't matter if you don't have to, try it a few times and you can still succeed.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

When the interface like the one above appears, you can breathe a sigh of relief, because the installation is complete, and now you can use Tensorflow, let's follow the tutorial and say hi to the world.

The way to enter the Python environment from Terminal is also very simple, directly enter the command: Python. If Python has been installed on the machine, Terminal will display the Python version number and other information, and the prefix of the next command will be changed from a string of characters such as the username to something like this: ">>>", which indicates that the entry is complete.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Type the code line by line according to the following command, I will not explain the syntax here~

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

In order to get to this point, you may have paid a lot of hardships, and you may have made a lot of mistakes in the middle, but I believe that when you see that the program really runs according to your instructions, you will feel that it is all worth it.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

#Egg time#

1. When programmers come into contact with a new language, the first thing they usually do is to write a Hello World program. This convention stems from the hope of the first batch of great gods for computer programs, hoping that they will be like a freshman. Like a child, it can be kind to the world to announce its arrival.

2. The meaning of the number 42 is very profound. According to the famous sci- fi novel The Hitchhiker's Guide to the Galaxy, 42 is the answer to a question about "life, the universe, and everything" (huh? You asked me what the question was?). The founders of Google are likely also big fans of the novel, as Google embeds the Easter egg in their search engine , and there's a "42" model outside Google's headquarters.

Essential for large-scale program development: IDE (Integrated Development Environment)

Although it can be programmed directly in Terminal, we always need a tool, otherwise it is almost impossible to compile a large program. This is where IDEs come in. Everyone will be pleasantly surprised to find that the familiar programming interface that you have seen in C language before is back (of course, many of them are charged). In fact, since Python is open source, theoretically anyone smart enough can develop an IDE for it, and many people do. There are too many great people, and there is no unified opinion on which tools they make are better or worse, so everyone simply does not introduce which one to use, which has caused many people to feel "abstract" of Python.

There are many IDEs that are easy to use. This article introduces Komodo Edit, the free version of Komodo IDE. Open its official website under Linux (click on the link http://komodoide.com/download/edit-linux64/#), and download a compressed file. Right click to unzip.

The method of installing some third-party software in Linux is not the same as that in Windows. For example, this one has an install.sh in its folder.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

This is actually the installation file, but it is not possible to open it directly. To install it, it has to be done in Terminal. Enter Terminal, make sure you are in a normal rather than a Python environment, and then enter the folder where the installation file is located by entering cd + folder name, layer by layer, if you enter the Download folder, enter: cd Download ( Python is case-sensitive, Therefore, it is best to develop the habit of distinguishing between upper and lower case when typing. ), because when you enter an installation command, the program will only search for the name of the installation file in the folder you are currently in (excluding subfolders). . People who are used to graphical interfaces may be a little dizzy, but you can find your way home as long as you keep the following in mind: When you open Terminal, the default file manager interface corresponding to the folder you are in is the one below. In the initial stage, you can open the folder with the graphical interface and type the corresponding path in Terminal, so that you will not get lost.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Of course, some software has simpler installation methods, which will not be discussed here.

After reaching the interface where the installation file is located, enter ./+ file name, such as ./install.sh in this example, the effect is as follows:

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

According to the path given in the information, you can find the file that starts the program. The file in this example is in bin.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

The next settings are almost the same as in Windows.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

After opening, let's use it to test a relatively simple algorithm given in the "Introduction" section of the official tutorial .

Click on New File

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Click on the language selection in the upper right corner and select Python, so that you can check for some syntax errors during the typing process.

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

(If you copy it directly, it will also bring some strange codes in the webpage, which will cause the program to run incorrectly, as in the following example, so you need to delete the Chinese comments.) Save the entered code as *.py, which is the extension of the Python file. Can be called through Terminal. Enter the folder where the files are stored in Terminal according to the previous method. The path in this article is as follows:

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Then enter Python + filename, in this case Python Text-3.py, since the algorithm is simple, the result will be obtained quickly. Do you have a full sense of achievement?

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Step by Step really starts from scratch, TensorFlow detailed installation introductory graphic tutorial!  Help you to complete the hardest from 0 to 1

Summarize

In fact, this tutorial is just a very small start, explaining some of the most basic knowledge about Tensorflow, including installation in other environments, GPU support and other slightly more complicated things. But in fact, this process from 0 to 1 is the biggest factor that stumped many people. After understanding these things in the tutorial, I believe that it is not difficult for you to understand the official tutorial of Tensorflow. If you follow the official tutorial, you will find that these things are not difficult. I believe you can learn it with your wisdom. . So that's it for this tutorial. Come on, everyone, maybe it's you who will create the next AlphaGo.

The title map comes from the Tensorflow official website

TensorFlow pdf learning materials Baidu network disk download:

Link: https://pan.baidu.com/s/1IQddyGm0LGzhNfDJw_kUUg

Password: sbjj

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324378092&siteId=291194637