Pytorch Learning Series Tutorials: Introduction to Getting Started

guide

I still have to cheer up in the new year. This official account has been silent for almost two months before and after the festival. I haven’t updated the original tweets for a long time. I feel that I can’t go down like this anymore. So recently I have been thinking about what tweets to write: not only to meet the needs of the current work, to force growth; but also to benefit the readers, not just to promote operations.

So, I finally decided to "get involved" in the direction of deep learning, and planned to update a wave of Pytorch learning tutorials first. Of course, this will be a series.

a1fba850fbe32d8a6eb98249ec37f12b.png

torch, original meaning "torch"

When it comes to Pytorch, we have to start with deep learning. Anyone who is engaged in data-related positions knows that deep learning is a sub-direction of machine learning. It mainly uses neural networks as the basic module, and realizes specific model functions by flexibly combining a certain number of layers of networks. It is especially good at computer vision (CV) and Natural language processing (NLP) direction. In its development history, after experiencing two high tides and two low valleys, it is currently in the third booming period of rapid development.

82631952df23aa6a2929af9e7de49646.png

network map, intrusion and deletion

Here, the depth of deep learning is mainly reflected in the fact that the number of model layers constructed is large, so it is called "deep"; The lecture should be called deep learning based on neural networks. Naturally, it may not be based on neural networks. For example, Zhou Zhihua's team explored and proposed a deep random forest model a few years ago, which can be said to have proposed a new research idea for deep learning.

From theoretical research to industrial application, mature industrial-grade implementation is inevitable. Based on the python language, for the classic machine learning model, scikit-learn must be known to everyone; and when it comes to deep learning, the corresponding toolkit is not so "centralized and unified", and it can even be called a big one. Factory disputes. Among them, the most representative and widely used are TensorFlow and Pytorch. The former originated from Google, and the latter was published on Facebook; the former is mostly used in industrial applications, while the latter is popular in academia. Of course, there is no clear boundary between academia and industry alone.

At first, after learning that TensorFlow is widely used in the industry, and I have been far away from colleges and universities, I entered TensorFlow directly. I have been a TF boy for a while, especially when I learned that TensorFlow2.0 has overcome the much criticized static Figure problem, so I don't think TensorFlow has any shortcomings. But later, with the in-depth study and the understanding of colleagues around me, I found that Pytorch has more excellent features: for example, the design is closer to Numpy, the syntax style is more Pythonic, and so on. Therefore, the individual also decisively switched to the Pytorch camp.

As the first article, this article is only used to introduce what Pytorch can do, and my personal understanding of why it is designed this way.

Torch is an old-fashioned deep learning framework. It was first developed based on the lua language. Due to the niche nature of its development language, its development and application are also subject to many restrictions. Since Facebook open sourced the Torch toolkit of the Python ecosystem - Pytroch, it has been a heavyweight tool that rivals TensorFlow. Currently Pytroch has 54k stars on GitHub (TensorFlow currently has 163k stars on GitHub, the gap is still relatively large, about 3 times as much).

It is precisely because the most extensive stage of deep learning lies in the application direction of image, voice and text, so three toolkits and one model service toolkit are matched with Pytorch:

  • torchvision

  • torchtext

  • torchaudio

dc201aeca40d59e0794e443fa620e2f3.png

Of course, Pytorch is still the foundation and core

As a deep learning toolkit, what can Pytorch be used for? The description of its positioning is quoted here from the official document. In a broad sense, it has two functions:

349b001c90f4189ffa75f3ed64f16af0.png

Right now:

  • Supports GPU-accelerated Tensor computing capabilities

  • Construction of deep neural network that supports automatic derivation

Then the question comes: It is said that Pytorch is a deep learning tool, why is its core function designed as the above two points? In this regard, my personal understanding is as follows:

One: Tensor is the foundation of deep learning model construction and training. Its status is like that of array to Numpy and DataFrame to Pandas. It is a data structure itself, but it constitutes the soul of Pytorch. Here, the original meaning of Tensor in English is "tensor", which actually corresponds to a multidimensional array, which is essentially the same as numpy's ndarray.

From this point of view, Pytorch can be regarded as an upgraded version of numpy. The upgrade here is mainly reflected in the ability to use the powerful parallel computing capabilities of the GPU. If you have a Numpy foundation, learning Pytorch can actually be very simple; on the other hand, learning Pytorch can also be used as a supplement to Numpy, regardless of the purpose of building a deep learning model.

Second: Pytorch is positioned as a deep learning tool, and its more main function is to support the construction and training of deep learning models. At the same time, unlike the mature models in classical machine learning, most deep learning networks do not have fixed models or paradigms, but are generally composed of users who flexibly match multiple basic modules (of course, there are actually some mature models , such as LeNet-5, AlexNet and VGGNet, etc., but more generally users still need to customize), so Pytorch's support for deep learning does not lie in how many mature models are integrated, but in providing basic deep learning modules. These are like scaffolding, which can be combined and matched arbitrarily to achieve more freely customized functions.

The functions of Pytorch are relatively rich and complicated. The best learning platform is to consult its official documentation, https://pytorch.org/. Due to the extensiveness of the Pytroch community, its documents currently support multiple languages, including Chinese documents, which also provides more channels for self-students to get started quickly. I personally benefited from it, and subsequent tweets will also use this as an important frame of reference.

542b310ef0b6ffe5f72ac7478d72c83f.png

That's all for this tweet, from tool introduction to model modeling, and a series of Pytorch learning tweets will be updated every week.

ebd098963f48a57d667df1de5d2a5fa4.png

Related Reading:

Guess you like

Origin blog.csdn.net/weixin_43841688/article/details/122935293
Recommended