Transforms mechanism and data standardization

Articles and codes have been archived in [Github warehouse: https://github.com/timerring/dive-into-AI ] or the public account [AIShareLab] can also be obtained by replying to the pytorch tutorial .

Image preprocessing transforms

transforms operating mechanism

torchvision: computer vision toolkit

  • torchvision.transforms

    Commonly used image preprocessing methods, such as:

    • data center
    • data standardization
    • zoom
    • cut out
    • to rotate
    • turn over
    • filling
    • noise addition
    • grayscale transformation
    • linear transformation
    • affine transformation
    • Brightness, Saturation, and Contrast Transformation

  • torchvision.datasets

    The dataset implementation of common datasets, MNIST CIFAR 10 ImageNet etc.

  • torchvision.model

    Commonly used model pre-training, AlexNet VGG ResNet GoogLeNet etc.

The mechanism by which transforms operate

Data normalization transforms.normalize

transforms.Normalize

The meaning of standardization is to change the mean of the data to 0 and the standard deviation to 1.

Function: Normalize images channel by channel

output = (input - mean) / std

  • mean : the mean of each channel
  • std : the standard deviation of each channel
  • inplace : Whether to operate in place

Normalizing the data can speed up the convergence of the model. By comparing different experimental results, it can be seen that a good data distribution is more conducive to the overall convergence of the model.

Guess you like

Origin blog.csdn.net/m0_52316372/article/details/131609665