当前位置:网站首页>【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()
边栏推荐
猜你喜欢
随机推荐
no matching host key type found. Their offer: ssh-rsa
jsArray数组复制方法性能测试2207292307
CMake库搜索函数居然不搜索LD_LIBRARY_PATH
RTSP/Onvif协议视频平台EasyNVR服务一键升级功能的使用教程
How to display an Excel table in the body of an email?
R语言ggpubr包的ggboxplot函数可视化分组箱图、自定义移除可视化图像的特定对象(移除可视化图像轴坐标轴的刻度线标签文本、both x and y axis ticks labels)
第十五天笔记
05 | 后台登录:基于账号密码的登录方式(下)
Self-tuning PID self-tuning control 】 【
Why is Prometheus a monitoring artifact sufficient to replace Zabbix?
dolphinscheduler单机化改造
20220729 证券、金融
There is no one of the strongest kings in the surveillance world!
ES6 Set与Map是什么,如何使用
Tutorial on using the one-key upgrade function of the RTSP/Onvif video platform EasyNVR service
Yilian: Activating the Value Potential of Data Elements and Unleashing the Innovation Dividend of SAS SSD
SQL 26 calculation under 25 years of age or older and the number of users
EasyNVR更新版本至(V5.3.0)后页面不显示通道配置该如何解决?
Lake storehouse which electricity (2) of the project: project using technology and version and the environment
dolphinscheduler简单任务定义及复杂的跨节点传参









