Kau*_*l28 6 machine-learning neural-network regularized deep-learning dropout
我正在从deeplearning.ai课程中学习神经网络中的正则化。在 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
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,为什么激活被除以0.8或将节点保留在层中的概率 ( keep_prob)?任何数字示例都会有所帮助。
Kau*_*l28 10
在花了一些时间了解倒退辍学后,我自己得到了答案。这是直觉:
我们以概率 保留任何层中的神经元keep_prob。让我们说kepp_prob = 0.6。这意味着关闭任何层中 40% 的神经元。如果在关闭 40% 的神经元之前该层的原始输出为x,那么在应用 40% 的 dropout 后,它将减少 0.4 * x. 所以现在将是x - 0.4x = 0.6x。
为了保持原始输出(期望值),我们需要将输出除以keep_prob(或0.6此处)。
| 归档时间: |
|
| 查看次数: |
880 次 |
| 最近记录: |