如何在卷积神经网络中使用 Keras 实现 Monte Carlo dropout 以估计 YARIN GAL 建议的预测不确定性?我正在使用 R。R-Code is here
我正在小批量地拟合模型,并希望通过蒙特卡罗辍学小批量地评估模型。在 Keras 文档中找不到任何提示。顺便说一句,我用标志训练 = TRUE 训练了我的模型。
谢谢
最佳答案
常规 dropout 仅在训练时随机丢弃神经元,而不是测试时,因此这是 Dropout
的默认行为。类(class)。如果你想要MC dropout,你需要使用training=TRUE
在测试时也是如此,您必须多次运行前向传递:这将为您提供预测分布,您可以随意使用,例如计算平均值。
我对 R 不够熟悉,所以这里是我使用的类而不是标准 Dropout
类(class):
class MCDropout(keras.layers.Dropout):
def call(self, inputs, training=None):
return super(MCDropout, self).call(inputs, training=True)
关于r - 蒙特卡洛 (MC) 在 Keras 中使用 R 退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50023666/