laitimes

Introduction to Deep Learning is a first introduction to PyTorch

author:Practice basic IT skills

Today's National Day, I wish our motherland prosperity, but also wish us programmers an early winter, and wish everyone a happy National Day Mid-Autumn Festival. The holiday is not busy, you can quickly update some basic knowledge, today is mainly along the previous article and introduce you to what is PyTorch and Tensor, which is the basis of everything.

Introduction to Deep Learning is a first introduction to PyTorch

PyTorch is recognized by top AI companies

PyTorch is currently the most popular deep learning framework, surpassing TensorFlow, and in my current knowledge, PyTorch is indeed relatively easy to use, which is convenient for beginners to get started.

Introduction to Deep Learning is a first introduction to PyTorch

Shares and trends are constantly getting higher

Some of the features of PyTorch can be summarized:

  • It is currently the most popular framework for studying deep learning.
  • Deep learning code can be written using python, and the code can be quickly migrated to GPU or multi-GPU environments.
  • Users can easily use some of the embedded deep framework models embedded in the torchvision package, such as Transformer, ResNet, etc.
  • Support the whole life cycle of deep learning, such as preprocessing data, building models, and deploying your models on various devices.
  • There are many large factory endorsements, you can learn and use with confidence. For example, Meta, OpenAI, Mircosoft, etc.

At present, PyTorch is indeed the first thing we should start with when learning deep learning, and I will not repeat it here, since you can read this article carefully, you must have a certain understanding of PyTorch. Next, let's get to know what Tensor is for the first time, everyone must be like me, don't rush, quickly pass Tensor, and then start to quickly learn the following content. In the end, it will only touch you with a full head of bags, or you need to return to this link of Tensor, you need to master the operation of Tensor very thoroughly, you can learn the following knowledge with ease.

First of all, let's install PyTorch and jupyter notebooks locally, and I won't go into them here. If you feel troublesome, you can go online to search for cloud products, search for PyTorch's interactive environment, if you can open Google Colab it is better, you can try the GPU for free, and you can also skip the most hated environment configuration link for novices (here you must pay attention to this step is easy to get from entry to relaxation, if you can't get the GPU at the beginning, you can first install the environment of the PyTorch CPU, remember to run the code at the beginning), start jupyter Notebook or Jupyter Lab is relatively simple, as long as it is installed, find a workspace for your subsequent work and type the command "Jupyter Lab" in the following figure to start.

Introduction to Deep Learning is a first introduction to PyTorch

The next step is to import torch, knock out the iconic "hello world" of any programming language or framework, as shown in the figure below, this is my hometown computer, the version of PyTorch is also relatively old, but it also supports GPU, you can use the command torch.cuda.is_available() to see if cuda is available.

Introduction to Deep Learning is a first introduction to PyTorch

Torch's version

Introduction to Deep Learning is a first introduction to PyTorch

Basic information about NVIDIA

Introduction to Deep Learning is a first introduction to PyTorch

Well, so far, don't be trapped by the environment, don't say that in order to learn deep learning, first buy a computer with a high graphics card, I don't think at all at this stage. If you can last for 3 months (in the same situation as me), you can rent a GPU for a long time. This gives you motivation to keep writing code and deploying models. It can be run inside the cloud host. To get back to business, now you just need to successfully install PyTorch to run successfully torch.__version__ don't be obsessed [slap in the face]

Introduction to Deep Learning is a first introduction to PyTorch

In the next few sections, we'll get started with the ubiquitous Tensor in PyTorch. I will share with you based on my current shallow experience that some of the cores of our subsequent operation of Tensor are also APIs that we must care about, and we also need to operate some of our commonly used APIs, of course, we will also cover all the important APIs, and some of the cores if used later in convolutional neural networks and transformers, we will also have a separate section for a separate introduction.

If you are interested, you can collect and follow, and we continue to learn.

Read on