当前位置:网站首页>【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
边栏推荐
- Personal decoration notes
- 序列化、监听、自定义注解
- Ape anthropology topic 20 (the topic will be updated from time to time)
- Graduation season, I want to tell you
- 2.2 【pytorch】torchvision.transforms
- Nacos - Configuration Management
- Shell脚本-位置参数(命令行参数)
- Shell script - array definition and getting array elements
- Shell script - positional parameters (command line parameters)
- Imitation of Baidu search results top navigation bar effect
猜你喜欢

3D printing Arduino four axis aircraft

大型工厂设备管理痛点和解决方案

Football and basketball game score live broadcast platform source code /app development and construction project

Ape anthropology topic 20 (the topic will be updated from time to time)

FAQ | FAQ for building applications for large screen devices

钓鱼识别app

Understanding and implementation of AVL tree

2.4 激活函数

3. Detailed explanation of Modbus communication protocol

nacos简易实现负载均衡
随机推荐
Football and basketball game score live broadcast platform source code /app development and construction project
Class loading
How to manage fixed assets efficiently in one stop?
Databinding source code analysis
Dynamic proxy
Jetson Nano 安装TensorFlow GPU及问题解决
How to effectively align team cognition
Nacos - service discovery
VSYNC+三重缓存机制+Choreographer
It is designed with high bandwidth, which is almost processed into an open circuit?
Win7 pyinstaller reports an error DLL load failed while importing after packaging exe_ Socket: parameter error
nacos簡易實現負載均衡
DataBinding源码分析
Shell脚本-特殊变量:Shell $#、$*、[email protected]、$?、$$
易点易动助力企业设备高效管理,提升设备利用率
大型工厂设备管理痛点和解决方案
JCL 和 SLF4J
Log4j log framework
树结构---二叉树1
Phishing identification app