当前位置:网站首页>paddlepaddle 20 指数移动平均(ExponentialMovingAverage,EMA)的实现与使用(支持静态图与动态图)
paddlepaddle 20 指数移动平均(ExponentialMovingAverage,EMA)的实现与使用(支持静态图与动态图)
2022-06-27 01:59:00 【万里鹏程转瞬至】
指数移动平均(ExponentialMovingAverage,EMA)是以指数式递减加权的移动平均,每一次更新都对上一次保留的权重按照decay进行衰减。其计算方式为pram_n'=(pram_n'-1)*decay+(1-decay)*pram_n,其中pram_n'为EMA保存的在n步时的权重,pram_n为算法正常计算得出的权重。
EMA是一个不断迭代的运算方式,在第n步时,第k次更新参数被衰减了decay^(n-k)倍。EMA本质就是一种学习率衰减的策略,具体可见博客(https://www.cnblogs.com/sddai/p/14646581.html)中的推导,此外,该作者还实现了pytorch版的EMA。
在paddle2中EMA可分为静态图版和动态图版,静态图版官方已经在paddle2.0中进行实现,下面会进行简单介绍。动态图版需要自行实现,将在本文的第二节实现。在训练模型一开始ema就生效,会使ema_model在测试集的表现极差,因为这个阶段的模型更新较少,其权重的大部分都是刚刚初始化的。建议在训练一定阶段后启用ema。
1、静态图版EMA
官网的介绍 https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/static/ExponentialMovingAverage_cn.html#exponentialmovingaverage
导入 只能用于静态图
from paddle.static import ExponentialMovingAverage初始化 </
边栏推荐
- Oracle/PLSQL: From_Tz function
- Dameng database installation
- Arbre binaire OJ sujet
- Would rather go to 996 than stay at home! 24 years old, unemployed for 7 months, worse than work, no work
- memcached基础13
- 1.44 inch TFT-LCD display screen mold taking tutorial
- memcached基础9
- Oracle/PLSQL: Lower Function
- jwt的认证流程和使用案例
- 为什么传递SPIF_SENDCHANGE标志SystemParametersInfo会挂起?
猜你喜欢

二叉樹oj題目

Cvpr2022 | pointdistiller: structured knowledge distillation for efficient and compact 3D detection

SQLite Reader 插件测试SQLite语法

Some exception handling for idea plug-in development

Summary of config mechanism and methods in UVM (2)

dat.gui.js星星圆圈轨迹动画js特效

宁愿去996也不要待业在家啦!24岁,失业7个月,比上班更惨的,是没班可上

I encountered some problems when connecting to the database. How can I solve them?

Svg drag dress Kitty Cat

C language -- Design of employee information management system
随机推荐
Flink學習2:應用場景
为什么先划分训练集和测试集后归一化?
Oracle/PLSQL: HexToRaw Function
执念斩长河暑期规划
P5.js death planet
Did your case really pass?
Addition, deletion, modification and query of ymal file
D's appendto packaging
memcached基础10
The listing of Fuyuan pharmaceutical is imminent: the net amount raised will reach 1.6 billion yuan, and hubaifan is the actual controller
Shell脚本系列篇(1) 入门
二叉树oj题目
Why divide the training set and the test set before normalization?
memcached基础12
UVM in UVM_ config_ Use of DB in sequence
memcached基础11
宁愿去996也不要待业在家啦!24岁,失业7个月,比上班更惨的,是没班可上
达梦数据库安装
CVPR2022 | PointDistiller:面向高效紧凑3D检测的结构化知识蒸馏
Memcached basics 13