将 Keras 与 TensorFlow 后端一起使用时的丢失

Dropout when using Keras with TensorFlow backend

我阅读了有关 dropout 的 Keras 实现,它似乎正在使用它的反向 dropout 版本,尽管它说的是 dropout。

这是我阅读 Keras 和 Tensorflow 文档时的理解:

当我指定 Dropout(0.4) 时,0.4 意味着该层中的每个节点都有 40% 的机会被丢弃,这意味着 0.4 是丢弃概率。因此,根据反向丢失的概念,剩余神经元的输出按 1/0.6 的比例缩放,因为保留概率为 0.6。

(如果我的解释不正确请指出,我所有的疑问都是基于这个解释。)

另一方面,在 TensorFlow 中,它直接询问保持概率,这意味着如果我指定一个值 0.4,每个节点有 60% 的机会被丢弃。

那么当我在 Keras 后端使用 TensorFlow 时会发生什么?保留或丢弃概率需要 0.4 吗?

(使用 Python 3.6 和所有必需库的最新版本)

Dropout(0.4) 在 Keras 层中意味着 40% 的神经元被 丢弃(未保留)。

来自Keras documentation

Dropout consists in randomly setting a fraction rate of input units to 0 at each update during training time, which helps prevent overfitting.

查看 Dropout 层的 source code (Line 72) 也可以帮助确定答案。

Dropout consists in randomly setting a fraction "rate" of input units to 0 at each update during training time, which helps prevent overfitting.

消息来源还提到了一篇由 Nitish Srivastava 等人撰写的参考论文(我假设它准确概述了 keras 如何实现 dropout)found here。 al.


虽然多读了一点源代码,但它似乎在第 107 行附近调用了 droput 的后端实现

return K.dropout(inputs, self.rate, noise_shape, seed=self.seed)

其中 K 是后端。如果您仍然好奇,可能值得研究一下 K.dropout 在您选择的后端中是如何实现的。