machine-learning - 反转 dropout 如何补偿 dropout 的影响并保持期望值不变?

标签 machine-learning neural-network deep-learning regularized dropout

我正在从 deeplearning.ai 学习神经网络中的正则化类(class)。在 dropout 正则化中,教授说如果应用 dropout,计算的激活值将小于未应用 dropout 时(测试时)。所以我们需要扩展激活以保持测试阶段更简单。

我明白这个事实,但我不明白缩放是如何完成的。这是一个用于实现反向 dropout 的代码示例。

keep_prob = 0.8   # 0 <= keep_prob <= 1
l = 3  # this code is only for layer 3
# the generated number that are less than 0.8 will be dropped. 80% stay, 20% dropped
d3 = np.random.rand(a[l].shape[0], a[l].shape[1]) < keep_prob

a3 = np.multiply(a3,d3)   # keep only the values in d3

# increase a3 to not reduce the expected value of output
# (ensures that the expected value of a3 remains the same) - to solve the scaling problem
a3 = a3 / keep_prob  

在上面的代码中,为什么激活被除以 0.8或将节点保留在层中的概率( keep_prob )?任何数字示例都会有所帮助。

最佳答案

在花了一些时间了解倒退辍学后,我自己得到了答案。这是直觉:

我们以概率 keep_prob 保留任何层中的神经元.比方说 kepp_prob = 0.6 .这意味着关闭任何层中 40% 的神经元。如果在关闭 40% 的神经元之前该层的原始输出是 x ,然后在应用 40% dropout 后,它将是 减少了 0.4 * x .所以现在是 x - 0.4x = 0.6x .

为了保持原始输出(期望值),我们需要将输出除以 keep_prob (或 0.6 在这里)。

关于machine-learning - 反转 dropout 如何补偿 dropout 的影响并保持期望值不变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57193633/

相关文章:

matlab - (matlab) 具有 relu 和 softmax 的 MLP 不适用于小批量 SGD,并在 MNIST 数据集上产生类似的预测

machine-learning - 具有文本特征的数据集的逻辑回归

python - 我在 python 中使用 sklearn 进行文本分类的管道配置

python - 基于神经网络的文档排名

python - 使用 ImageDataGenerator 时 Keras 训练速度很慢

python - 来自 Google 的 TensorFlow - 数据安全

neural-network - Caffe 准确率大于 100%

machine-learning - 用于将文档集合转换为 LibSVM 格式的实用程序

Python/ tensorflow : Saver for network

python - Pytorch 中的 LSTM