Python keras ReLU层的意外输出

Python keras ReLU层的意外输出,python,keras,threshold,relu,Python,Keras,Threshold,Relu,在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. f(x)=x的最大值>=最大值, f(x)=x表示阈值源代码中的文档是错误的。

在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.
f(x)=x的最大值>=最大值,

f(x)=x表示阈值源代码中的文档是错误的。(您应该转到
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.
f(x)=x的最大值>=最大值,
-->f(x)=阈值
因此,当您的
x
==
threshold
时,它进入第三种情况,其中包含
0
(即
x-threshold
)。这就是为什么会得到
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.
f(x)=x的最大值>=最大值,
-->f(x)=阈值
因此,当您的
x
==
threshold
时,它进入第三种情况,其中包含
0
(即
x-threshold
)。这就是为什么会得到
0

如果您需要记录行为,则需要根据需要进行更改


x=x*tf.cast(tf.greater_equal(x,阈值),floatx())

请编辑您的问题,而不是将详细信息作为答案发布。事情会更清楚。请编辑您的问题,而不是将详细信息作为答案发布。事情会清楚得多。我自己无法在tensorflow中找到ReLU代码。。。谢谢!!我自己无法在tensorflow中找到ReLU代码。。。谢谢!!