In the previous stage, Microsoft officially opened the PTCK (Computational Network Toolkit). In Chinese, there is artificial intelligence. But the actual English word translation is actually a computing network toolbox. From another perspective, it can be understood as a kind of A way to implement artificial intelligence through calculations.
The seemingly professional name must be followed by a certain mathematical foundation. In this series of articles, we should try to explain these mathematical principles using popular language. If necessary, we will give relevant links (it may also be that we write articles separately) In summary, it is also possible to be an external chain).
This is a new thing, there is very little information on the Internet, so if there is a place in my article that I personally understand the mistake, please correct me so that I don't miss my children.
What is CNTK specifically?
According to my current understanding, CNTK is a set of tools. Some people may have heard about deep learning or neural networks. Some people have seen some tutorials on Stanford's neural network. CNTK is just a framework or a set. Simple tools help us achieve the deep learning we are involved in or the neural network. Many classic algorithms have been integrated. Of course, you can also define your own specific algorithms or input and output methods according to the actual situation.
What problems can CNTK solve? (only this I can think of now)
- Category Analysis
- Speech Recognition
- Image Recognition
- Fast, really fast, Microsoft has been emphasizing this
- support CUDA-based GPU computing, of course, also supports pure CPU
- easy to use training
Formally introduce CNTK
The above picture is the overall structure of CNTK. Here we can easily understand the parts in two parts: upper middle, lower left, middle left and right.
First, the middle and lower, the bottom layer contains the IDataReader layer can be understood as the basic data, you want to train a pawn shop to identify the authenticity of the antique, you need to take some real fake fake antiques to let him go Comprehend, this is the process of learning, and the input process of the initial data. The result of learning is the second layer of things that contain CN. The CN abbreviation here does not know whether it is a Computational Network. I understand the Computational Network or the model of the neural network. It can be understood that the pawnshop children understand the knowledge of the brain through the true and false antiques. The top IExecutionEngine can be understood as the personal behavior of the pawnshop. The customer took an antique and asked him to identify the true and false. This is the top role or meaning.
Second, left, right, left, is the input of the original data, here introduced the CN Description is the description of the network, can be understood as the guidance of the pawn's child's master or the antique identification textbook, and the Features in Features & Labels is the sample Or antiques, Labels can be understood as labels on antique samples that are true and false. In the middle is ICNBuilder is the driving force of learning behavior, IDataReader is the drive to carefully observe and test the behavior of the content. The rightmost ILeaner is the learning method. CN explained the result of learning before, and IExecutionEngine is the behavior that finally brings the real thing to test.
In short, the overall structure of CNTK describes the learning process from entry to proficiency of a pawnshop. Train yourself from the sample, form your own abilities, and then use what you have learned.
Simple description of neural network
(People who are familiar with the neural network or who know a little can skip this section at will, in order to make it possible to understand the new, so write this part, of course, you can read it in a single line.)
The structure diagram of CNTK gives a learning process, learning various methods. We introduce a method of comparative bionics here, which is the term "neural network".
The term neural network, as its name implies, mimics the network into which neural cells are connected. He mimicked the nerve cells of the creature. For example, the optic nerve starts from the retina and eventually reaches the visual recognition part of the brain. The retina converts the light signal into a neural signal (bioelectric signal?), which then passes through several levels of conduction and is ultimately transmitted to the visual processing part of the brain, which is ultimately classified into a category, such as "I see a cat." Here we can only perceive the input "images seen" and the resulting consciousness "cats", and the conduction process of the nerve cells in the middle may not be clear.
Artificial neural network (AN), referred to as neural network (NN), is a mathematical model or calculation that mimics the structure and function of biological neural networks (the central nervous system of animals, especially the brain). model. The neural network is calculated by a large number of artificial neuron connections. In most cases, an artificial neural network can change the internal structure based on external information, and is an adaptive system. Modern neural networks are a kind of nonlinear statistical data modeling tools that are commonly used to model complex relationships between inputs and outputs, or to explore patterns of data.
A neural network is an operational model consisting of a large number of nodes (or "neurons", or "units") and interconnected. Each node represents a specific output function called an activation function. The connection between every two nodes represents a weighting value for passing the connection signal, called weight, which is equivalent to the memory of the artificial neural network. The output of the network varies depending on the connection method of the network, the weight value and the excitation function. The network itself is usually an approximation of an algorithm or function in nature, or it may be an expression of a logic strategy.
Where a single neuron can be expressed as described in the following figure,
A neuron may not be able to make anything, but a neural network containing several neurons is richly powerful or smarter. Refer to the simple case shown below,
Neurons seem relatively simple, and well understood, the same network is also very simple, it is also easy to understand, the so-called neuron network, is to link the neurons, connect the input and output, the connection here is different, it also appears The so-called different neural network algorithms currently deal with different functions and suitable situations.
Neural networks can be hierarchical, that is, the input layer, the hidden layer, and the output layer. The hidden layer is just a statement, which may contain several layers. Of course, the layer is just a way of describing it. In the final analysis, the interconnection of neurons.
I have already introduced too many introductions, introduced CNTK, introduced the neural network, and introduced the author's own understanding of this. The following is the real contact with CNTK.
Before you read this article, you may already know the official website of CNTK and the address of Github, but you may share this article with others. Others can check the official CNTK data at the address below.
CNTK official website: http://www.cntk.ai/
GINKub address of CNTK: https://github.com/Microsoft/CNTK
I don't recommend that beginners pull the code directly from Github to compile it themselves. Instead, I recommend downloading the compiled Binary version to get started. So in this section, I will introduce how to deploy Binary to run through a Sample. It is the so-called first-hand understanding, and then understand the mechanism after opening it. After further introductory articles in this series, the author will take everyone from Github to pull the code, manually compile, manually modify, and implement its own extension and deep exploration of the mechanism.
The first step is to download the compiled Binary version compression package.There are actually many versions of the operating system (Windows or Linux), and it is divided into whether to use CUDA-based GPU functions.
The addresses that can be referenced are as follows. Here is how to deploy and configure.
The specific download address is as follows, everyone downloads according to their own situation, this is the release page of CNTK.
You may find that there are many versions, windows, linux, this is okay, download according to your own situation, and then decompress, the specific use is basically the same.
In addition to the operating system, there are three versions of CPU-only, GPU, and GPU-1bit-SGD. If your environment can use CUDA (that is, you can use Nvidia's graphics card acceleration), then you can choose GPU, otherwise it is CPU, here to talk about 1big-SGD, this has said that its license problem, because of him It's not an MIT license itself, so Binary pulled it out and compiled it in one version. If you are not using it for business purposes, there is no problem, of course, see the license.
After downloading, unzip it, then go to the second step. There will be no problems in the first step. Please steadily proceed to the second step.
The second step is to solve the environmental problems that depend on it.(In fact, you can skip this step first, after executing the third part first, and then come back to check this step after encountering problems, because the essence of this step is to solve the environmental dependence problem of CNTK)
First of all, if you are a development environment installed VS2017 and so on (specifically referred to as Visual C++ Redistributable for Visual Studio 2017). That may not be a problem, but if you can't find what dll is missing, you can consider installing "Visual C++ Redistributable for Visual Studio 2017".
Second, if you are a GPU version, it is recommended to update the NVIDIA driver to the latest version and ensure that the CUDA feature is enabled. At the same time, according to the description, CNTK does not require the user to install the CUDA SDK itself, but it is recommended to install it.
Finally, check if the MS-MPI SDK is installed. MPI is something that C++ uses for multithreading programming, and Microsoft has included it as part of HPC.
The third step is to set the environment variableFirst, set an environment variable ACML_FMA to 0 (ACML_FMA=0) as written in the description.
(Someone may ask what is ACML_FMA, the author is also curious, searched the search, it seems to be related to the CPU instruction set. First set, wait for the later study of the code carefully, found in the detailed interpretation)
Secondly, I suggest setting a Path environment variable to the location of cntk.exe in CNTK (in fact, it is convenient for calling, although it can be specified in the command line, but it is more troublesome to modify the Sample file or knock the command line to take one more parameter. ), of course, this description did not write, just a suggestion under the current conditions of the author.
After completing the third step, the environment setup is basically completed. In the following section, we can try to run an example given in CNTK. As a temporary end to this chapter in this series of articles, this is also the basis for an introduction.
Run a supplied SampleIn order to verify the correct situation of the environment built in the previous section, and in order to meet the achievement of the CNTK entry conditions, we need to run a simple Sample to verify, here we choose the simplest example of Simple2d.
The author briefly introduces this Sample, which is an example of classification. The trained sample is a number of two-dimensional coordinates distributed on a plane, including X coordinates and Y coordinates, and each point is reduced to a type, drawn in the icon. As shown below.
The coordinates on the graph are the raw data of the training. The input file given in Sample is SimpleDataTrain.txt in the Data directory. Here, each row is an input data, the first value is X, and the second is Y, the first Three are categories 0 or 1. After training through these data. Use SimpleDataTest.txt to test to test the results of the training.
In the end you can form a neural network model as shown below.
First, open the familiar CMD (Win+R, cmd, Enter). Use the cd command to navigate to the Config directory.
Then, run the following command.
There are two things to do here, the first is training and the second is testing.
Observe the content shown in the following figure, that is, successful training and the test is completed.