【发布时间】:2021-01-15 23:23:10
【问题描述】:
我无法理解如何执行 Leaky ReLU 的反向传播。
我已阅读其他帖子,但由于缺少符号(不确定是什么),我仍然不太确定我是否理解。
如果我有 dA,或者当前层的激活,以及来自前向传播的缓存值 Z,这就是正确的实现:
def leaky_relu_backward(dA, cache):
"""
The backward propagation for a single leaky RELU unit.
Arguments:
dA - post-activation gradient
cache - 'Z' where we store for computing backward propagation efficiently
Returns:
dZ - Gradient of the cost with respect to Z
"""
Z = cache
# just converting dz to a correct object.
dZ = np.array(dA, copy=True)
# When z <= 0, we should set dz to .01
dZ[Z <= 0] = .01
return dZ
或者还有更多吗?在这篇文章中:How to implement the derivative of Leaky Relu in python? 答案显示在 return 语句上发生了乘法。不知道我是否需要。
【问题讨论】: