当前位置:网站首页>【pytorch】transforms. Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
【pytorch】transforms. Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
2022-07-01 09:08:00 【Enzo tried to smash the computer】
ransform.Normalize(): The tensor image is normalized by mean and standard deviation
Often see
transforms.Compose([transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
that transform.Normalize() How does it work ? Take the above code for example ,
ToTensor() Did two things :
- Change the gray scale from 0-255 Change to 0-1 Between , It normalizes each value to [0,1], The normalization method is relatively simple , Divide directly by 255 that will do
- take shape by (H,W, C) Of nump.ndarray or img To shape by (C, H, W) Of tensor
transforms.Normalize()
transforms.Normalize(std=(0.5,0.5,0.5),mean=(0.5,0.5,0.5)), Its function is to normalize the input to (0,1), Then use the formula "(x-mean)/std", Distribute each element to (-1,1)
image=(image-mean)/std
among mean and std Pass respectively (0.5,0.5,0.5) and (0.5,0.5,0.5) Make a designation . The original 0-1 minimum value 0 Has become a (0-0.5)/0.5=-1, And the maximum 1 Has become a (1-0.5)/0.5=1.
But I think many codes are like this :
torchvision.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
How does this group of values come from ? This set of values is from imagenet It's calculated by sampling in the training center .
summary :
Go over it normalize() After the transformation, the mean value becomes 0 The variance of 1( In fact, the maximum and minimum values are 1 and -1)
Each sample image becomes a mean value of 0 The variance of 1 The standard normal distribution of , This is the most common ( The greatest value of scientific research ) Sample data of
边栏推荐
- MySQL optimization
- 2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
- 2.4 激活函数
- Software Engineer Interview Question brushing website and experience method
- 【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
- R language observation log (part24) -- initialization settings
- [MFC development (17)] advanced list control list control
- 美团2022年机试
- Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
- 钓鱼识别app
猜你喜欢

【检测技术课案】简易数显电子秤的设计与制作

Daily practice of C language - day 80: currency change

【pytorch】2.4 卷积函数 nn.conv2d

2.4 激活函数

Imitation of Baidu search results top navigation bar effect

Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched

Nacos - 服务发现

小鸟识别APP

Vsync+ triple cache mechanism +choreographer

Principle and application of single chip microcomputer timer, serial communication and interrupt system
随机推荐
又到年中,固定资产管理该何去何从?
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的WS2812灯控系统
Mysql8.0 learning record 17 -create table
Shell script -for loop and for int loop
Promise异步编程
MySQL optimization
Shell脚本-变量的定义、赋值和删除
日常办公耗材管理解决方案
Understanding and implementation of AVL tree
Redis -- lattice connects to redis cluster
Nacos - 配置管理
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
pcl_ Viewer command
Log4j log framework
Meituan machine test in 2022
What are the differences between the architecture a, R and m of arm V7, and in which fields are they applied?
Shell脚本-if else语句
R language observation log (part24) -- initialization settings
Shell脚本-for循环和for int循环
The jar package embedded with SQLite database is deployed by changing directories on the same machine, and the newly added database records are gone