Pytorch Learning (Part 1)

Tram Ho

Hello everyone, welcome to my Pytorch Serie. I am just a mere enthusiast of artificial intelligence, trying to learn so that I can become a really good AI engineer in the future.Deep Learning with PyTorch

For those who are starting with this field, I think it will take me about 3-4 months to follow the articles on the website to at least understand what AI and machine learning are. Then follow the cs231n key, which includes a video of the lecture to learn more about deep learning. Then we will go into our Serie.

This series mainly shows how to use the Pytorch tool, a library that makes it easy to deploy deep learning algorithms easily, and moreover, to create useful AI products. The book that I used to learn is Deep Learning with PyTorch , anyone who wants to read English can use it directly or go to the homepage with tutorials to make it easier to learn. Oke, then let’s go find out what Pytorch is.

1. What is Pytorch?

The definition in the textbook reads: Pytorch is a library for the Python language, facilitating the construction of deep learning projects (Oh forget to use Pytorch, you must at least know how to program and know it. A little bit of python usage).

Using Pytorch makes it easier to build models, run training, and model testing with great ease. However, for this job, there are many other libraries and frameworks that cx can do, such as tensorflow, mxnet, Theano (dead) … So why do we learn Pytorch?

According to the book I read above, the author said:

  • Pytorch is extremely simple. This is staffed by many researchers as well as programmers, making it easy to learn, use, extend and debug.
  • Pytorch gives us the Tensor data type, this Tensor can keep in it data types such as numbers, vectors, matrices, arrays. With Tensor, we can use all kinds of calculations like using Python in a regular way (or like NumPy , if you don’t know this, please go back to read through the basic ML key and cs231n =))))
  • Pytorch also makes it possible to use the GPU and CPU for computation (the GPU can speed up the computations by more than 50 times, so don’t joke), and also supports optimizing numerical operations ( for even basic math.
  • And finally, Pytorch with its core uses C ++, which also greatly speeds up the real runtime, making deployment on production more feasible.

Looking at the above ideas you can also see that other frameworks like tensorflow can do it.

Yes, but for myself, I chose Pytorch because it is extremely easy to read and easier to get started with. Syntax in Pytorch is exactly the same as we use Python. With Tensorflow, things are a little more complicated with its computation mechanism, which makes reading and debugging a little bit confusing at times.

2. What can Pytorch do?

To answer this question, let’s figure out what Pytorch can do with a machine learning or deep learning project:

  • Despite being a Python library, most of Pytorch is written in C ++ and CUDA (the two most powerful ones in terms of speed and computational compatibility), with parallelism on GPUs. Along with that, Pytorch provides the ability to run directly from C ++ with speed support for deploying the model on production.
  • Pytorch is also compatible with any other python library, we can use it in combination without worry.
  • Pytorch provides Tensors multidimensional arrays, supports multiple data types, tensor operations that can be computed on both the CPU and GPU, and can be converted back and forth.
  • What’s even more powerful is that Pytorch’s autograd engine included in Tensors helps us to track the differential of any output against any corresponding input. This is extremely useful if you want to use techniques to analyze classes in deep learning networks (methods like GradCAM or CAM need this very much).
  • Pytorch also makes a fair amount of its pretrained and models available. It can also be used for tuning or weight initialization.
  • Today, there are also many ecosystems of Pytorch for tracking model build and train, model optimization, and model deployment (JIT, Torchscript, ONNX). Moreover, launched in 2020 is the combination of TorchServe and AWS to confront Google’s Tensorflow Serving , which promises to bring great power to Pytorch to the community.

Deep Learning with PyTorch

A simple machine learning project deployed with Pytorch will look like the image above, with the process not too complicated, but in depth, each problem has its own different implementation, which we will cover in the coming parts.

3. Summary.

In this part, I introduce a little bit about Pytorch library for deeplearning. As for the installation, I will not introduce here because the homepage has introduced extremely in detail, you can refer to . In the next post, we will go to Tensor, where love begins, which powers the development of deeplearning projects. Thank you for reading the article, have any questions or unreasonable comments below so I can know.

Share the news now

Source : Viblo