当前位置:网站首页>【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
边栏推荐
- Graduation season, I want to tell you
- Leetcode daily question brushing record --540 A single element in an ordered array
- Insert mathematical formula in MD document and mathematical formula in typora
- How to manage fixed assets efficiently in one stop?
- Which method is good for the management of fixed assets of small and medium-sized enterprises?
- VSYNC+三重缓存机制+Choreographer
- 毕业季,我想对你说
- [ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
- Shell script - array definition and getting array elements
- What are the differences between the architecture a, R and m of arm V7, and in which fields are they applied?
猜你喜欢
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
How to manage fixed assets efficiently in one stop?
3D printing Arduino four axis aircraft
安装Oracle EE
What are the differences between the architecture a, R and m of arm V7, and in which fields are they applied?
Principles of Microcomputer - internal and external structure of microprocessor
How to manage fixed assets well? Easy to point and move to provide intelligent solutions
如何解决固定资产管理和盘点的难题?
jeecg 重启报40001
3D打印Arduino 四轴飞行器
随机推荐
Differences among tasks, threads and processes
MySQL optimization
Imitation of Baidu search results top navigation bar effect
Shell脚本-位置参数(命令行参数)
Jetson Nano 安装TensorFlow GPU及问题解决
[ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino
Programming with C language: calculate with formula: e ≈ 1+1/1+ 1/2! …+ 1/n!, Accuracy is 10-6
Promise异步编程
Dynamic proxy
Nacos - Configuration Management
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
美团2022年机试
3D printing Arduino four axis aircraft
JCL and slf4j
Promise asynchronous programming
Shell script - definition, assignment and deletion of variables
Shell脚本-case in语句
2.2 【pytorch】torchvision.transforms
Flink interview questions
[interview brush 101] linked list