当前位置:网站首页>【Pytorch】如何在关闭batch-norm的同时保持Dropout的开启
【Pytorch】如何在关闭batch-norm的同时保持Dropout的开启
2022-07-30 13:19:00 【翁诗浩】
这是我在复现剑桥大学论文遇到的一个问题:
Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning
我使用ResNet网络+Dropout,但是batch-norm会影响评估时的输出结果,如果直接开始eval()会同时关闭Dropout,但是上述论文的核心思想就是:高斯过程+变分推断可以得到与NN+dropout相同的损失函数,在传统的神经网络中添加dropout之后,由于每个输入和每次前向传播dropout选择激活哪个神经元都是随机的,即使是相同的输入样本,得到的输出也有可能不一样,多次输入同一个样本,输出围绕均值上下浮动的程度就可以看成是模型的一种不确定性。
方法:
for m in model.modules():
if isinstance(m, nn.BatchNorm2d):
m.eval()
边栏推荐
猜你喜欢
What are the hard-core upgrades and applications that cannot be missed in Greenplum 6.0?
外包干了七年,废了。。。
el-table中el-table-column下的操作切换class样式
Raja Koduri澄清Arc GPU跳票传闻 AXG年底前新推四条产品线
How to display an Excel table in the body of an email?
TaskDispatcher source code parsing
Greenplum 6.0有哪些不可错过的硬核升级与应用?
ML之PDP:基于FIFA 2018 Statistics(2018年俄罗斯世界杯足球赛)球队比赛之星分类预测数据集利用DT决策树&RF随机森林+PDP部分依赖图可视化实现模型可解释性之详细攻略
树形dp小总结(换根,基环树,杂七杂八的dp)
如何判断自己是否适合IT行业?方法很简单
随机推荐
RTSP/Onvif协议视频平台EasyNVR服务一键升级功能的使用教程
Hand tearing read-write lock performance test
How to migrate the device data connected by RTSP of EasyCVR platform to EasyNVR?
第42讲:Scala中泛型类、泛型函数、泛型在Spark中的广泛应用
Scala基础:数组(Array)、映射(Map)、元组(Tuple)、集合(List)
Anaconda\Scripts\pip-script.py is not present ? 解决方案
第十四天笔记
Xms Xmx PermSize MaxPermSize 区别
Lake storehouse which electricity (2) of the project: project using technology and version and the environment
for循环的3个表达式执行顺序
SQL 26 calculation under 25 years of age or older and the number of users
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化箱图、width参数自定义箱图中箱体的宽度
These critical programs are missing or too old: ma
There is no one of the strongest kings in the surveillance world!
TaskDispatcher源码解析
一文读懂Elephant Swap,为何为ePLATO带来如此高的溢价?
程序员修炼之道:务以己任,实则明心——通向务实的最高境界
Heshu Group: Make smart cities smarter and make real life better
shell 编程规范与变量
手撕读写锁性能测试