Pytorch framework learning path (eight: image preprocessing - transforms)

Pytorch column

Pytorch Framework Learning Path (1: Tensor Introduction and Creation)
Pytorch Framework Learning Path (2: Tensor Operation)
Pytorch Framework Learning Path (3: Linear Regression)
Pytorch Framework Learning Path (4: Calculation Graph and Dynamic Graph Mechanism)
Pytorch Framework Learning path (five: autograd and logistic regression)
Pytorch framework learning path (seven: data reading mechanism DataLoader and Dataset)

ReadMe (Note)

For the Debug part in front of this article, please refer to the previous blog (which is related to the learning path of the Pytorch framework of the previous blog (seven: data reading mechanism DataLoader and Dataset) ), here for the convenience of everyone’s recall and understanding, I will also post The Debug process picture is shown, but the process explained in detail in the previous blog ( Pytorch Framework Learning Path (Seven: Data Reading Mechanism DataLoader and Dataset) ) will not be explained.

(1) Transforms operating mechanism

1.1, torchvision: computer vision toolkit

insert image description here

1.2. Commonly used image preprocessing methods

insert image description here

1.3, transforms (including video explanation recorded by myself)

本人对一下内容做的详细讲解视频链接:https://pan.baidu.com/s/1Ovn2dMiU0WRUFd0DFLUITg
提取码:dcbo

Before we explain in detail transforms, let's look at the picture below, transformsthe location of the distribution during our data import process.
insert image description here

First, let's take a look at the Debug process: the following dynamic diagram
Please add a picture description

Made a video explanation of the above Debug process (this part of the text is difficult to describe)

我相信大家对这个动态图看的迷糊,所以我单独录制了视频进行讲解。这里附上百度网盘链接,

链接:https://pan.baidu.com/s/1Ovn2dMiU0WRUFd0DFLUITg
提取码:dcbo

1.4、transforms.Normalize

1.3I have already explained the source code to you in the video, and I transforms.Normalizewill post a picture below for your understanding.
insert image description here

The role of Normalize

Normalize的作用:It can speed up the convergence of the model. Then how to understand this! Let's first review the logistic regression code I described in the Pytorch framework learning path (five: autograd and logistic regression) . The result is as follows:
insert image description here

As can be seen from the figure above, our data (0,0)is not far from the point, and here the model is running and iterating to the second 400time, and the accuracy is lossreached .0.04930.995

If we modify the distribution of the data so that the mean of the data is far away from the origin, then biasthe size of will work, initialization bias= 4. insert image description here
As can be seen from the results in the above figure, when we iterate to 700times, the accuracy is greater than or equal to 0.99, and loss= 0.1381, and in your In the process of running it yourself, it is obvious that 400after the first iteration, the iteration speed is very slow. From here we can see how important our Normalize is.

(2) Preview of the next section

transforms图像增强(一)

  • data augmentation
  • transforms - cropping
  • transforms - flip and rotate

Guess you like

Origin blog.csdn.net/weixin_54546190/article/details/125121243