在keras文档中,该函数keras.activations.relu(x, alpha=0.0, max_value=None, threshold=0.0)
定义为:
f(x) = max_value for x >= max_value,
f(x) = x for threshold <= x < max_value,
f(x) = alpha * (x - threshold) otherwise.
我做了一个小测试用alpha=0.01
,threshold=5.0
并max_value=100.0
和x=5.0
输出我得到的是f(x)=0.0
。
如果我没有记错的话,那x == threshold
我应该得到f(x)=x=5.0
。
谁能解释一下?
谢谢,
源代码中的文档是错误的。(并且您应该转到tf.keras
而不是keras
)。它应该是,
f(x) = max_value for x >= max_value,
--> f(x) = x for threshold < x < max_value,
f(x) = alpha * (x - threshold) otherwise.
因此,当您的x
==时threshold
,将转到其中包含a的第三种情况0
(即x - threshold
)。这就是为什么你得到0
。
如果您需要记录的行为,则此行需要更改为
x = x * tf.cast(tf.greater_equal(x, threshold), floatx())
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句