当前位置:网站首页>Pytorch学习记录(十):数据预处理+Batch Normalization批处理(BN)
Pytorch学习记录(十):数据预处理+Batch Normalization批处理(BN)
2022-04-23 05:43:00 【左小田^O^】
数据预处理
目前数据预处理最常见的方法就是中心化和标准化,中心化相当于修正数据的中心位置,实现方法非常简单,就是在每个特征维度上减去对应的均值,最后得到 0 均值()像素范围在[-128,127],以0为中心的特征。标准化也非常简单,在数据变成 0 均值之后,为了使得不同的特征维度有着相同的规模,可以除以标准差近似为一个标准正态分布,也可以依据最大值和最小值将其转化为 -1 ~ 1 之间。
Batch Normalization批处理(BN)
批标准化,简而言之,就是对于每一层网络的输出,对其做一个归一化,使其服从标准的正态分布,这样后一层网络的输入也是一个标准的正态分布,所以能够比较好的进行训练,加快收敛速度。

第一行和第二行是计算出一个 batch 中数据的均值和方差,接着使用第三个公式对 batch 中的每个数据点做标准化, 𝜖 是为了计算稳定引入的一个小的常数,通常取 10−5 ,最后利用权重修正得到最后的输出结果,非常的简单,下面我们可以实现一下简单的一维的情况,也就是神经网络中的情况
https://www.cnblogs.com/yongjieShi/p/9332655.html
https://zhuanlan.zhihu.com/p/69431151
nn.BatchNorm2d
from torch import nn
import torch
m = nn.BatchNorm2d(3) # bn设置的参数实际上是channel的参数
input = torch.randn(4, 3, 2, 2)
output = m(input)
版权声明
本文为[左小田^O^]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_45802081/article/details/120246971
边栏推荐
- Duplicate key update in MySQL
- Flutter 新一代图形渲染器 Impeller
- 线程的底部实现原理—静态代理模式
- JVM series (3) -- memory allocation and recycling strategy
- MySQL realizes master-slave replication / master-slave synchronization
- Excel obtains the difference data of two columns of data
- 【华为机试】考试得分总数(如何处理答错的情况?回溯一次,代表答错一题)
- Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
- AcWing 836. Merge set (merge set)
- SQL注入
猜你喜欢

开发环境 EAS登录 license 许可修改

filebrowser实现私有网盘

第36期《AtCoder Beginner Contest 248 打比赛总结》

MySQL的锁机制

Pilotage growth · ingenuity empowerment -- yonmaster developer training and pilotage plan is fully launched

Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别

Isosceles triangle - the 9th Lanqiao provincial competition - group C

2 - principes de conception de logiciels

AcWing 836. Merge set (merge set)

Issue 36 summary of atcoder beginer contest 248
随机推荐
Character recognition easyocr
引航成长·匠心赋能——YonMaster开发者培训领航计划全面开启
多线程与高并发(3)——synchronized原理
xxl-job采坑指南xxl-rpc remoting error(connect timed out)
你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问
开发环境 EAS登录 license 许可修改
mysql如何将存储的秒转换为日期
What is JSON? First acquaintance with JSON
金蝶EAS“总账”系统召唤“反过账”按钮
Linear sieve method (prime sieve)
Redis经典面试题总结2022
ES6之解构函数
2.devops-sonar安装
Strategy for improving the conversion rate of independent stations | recovering abandoned users
Duplicate key update in MySQL
Contract lock loophole
MySQL创建oracle练习表
Common protocols of OSI layer
Issue 36 summary of atcoder beginer contest 248
事实最终变量与最终变量