当前位置:网站首页>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: NumToDSInterval Function
- 速看!2022年6月编程语言排行榜出炉!第一名太牛啦
- Cvpr2022 | pointdistiller: structured knowledge distillation for efficient and compact 3D detection
- Oracle/PLSQL: Soundex Function
- [the path of system analyst] Chapter 6: duplicate demand engineering (case paper)
- Memcached foundation 9
- C language -- Design of employee information management system
- 达梦数据库安装
- jwt的认证流程和使用案例
猜你喜欢

Flink学习3:数据处理模式(流批处理)

ThreadLocal详解

Markdown table (consolidated)

"All majors are persuading them to quit." is it actually the most friendly to college students?

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

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

Installing the Damon database using the command line

Constraintlayout Development Guide

Summer planning for the long river
随机推荐
Oracle/PLSQL: Trim Function
为什么传递SPIF_SENDCHANGE标志SystemParametersInfo会挂起?
Due to the invalidation of the prospectus of bori technology, CICC has stopped providing guidance to it and abandoned the listing on the Hong Kong stock exchange?
WiFi-IoT 鸿蒙开发套件样例开发
Oracle/PLSQL: To_Clob Function
Flink学习3:数据处理模式(流批处理)
Oracle/PLSQL: From_ Tz function
D's appendto packaging
svg拖拽装扮Kitty猫
Oracle/PLSQL: Cast Function
Oracle/PLSQL: Lower Function
达梦数据库安装
Flink學習2:應用場景
perl语言中 fork()、exec()、waitpid() 、 $? >> 8 组合
d的appendTo包装
SQLite reader plug-in tests SQLite syntax
idea 插件开发一些异常处理
Oracle/PLSQL: HexToRaw Function
ConstraintLayout(约束布局)开发指南
热议:月薪1.8万却毫无意义的工作,你干吗?