在Tensorflow中使用漏洞relu

HYU*_*CHO 14 python neural-network tensorflow

怎么才能换G_h1 = tf.nn.relu(tf.matmul(z, G_W1) + G_b1)到漏水的relu?我试过使用张量来循环,max(value, 0,01*value)但是我得到了TypeError: Using a tf.Tensor as a Python bool is not allowed.

我也尝试在Tensorflow github上找到源代码,以便我可以修改它以泄漏relu但我找不到它..

Man*_*tos 25

如果alpha <1(它应该是),你可以使用 tf.maximum(x, alpha * x)


P-G*_*-Gn 24

您可以根据以下内容编写一个tf.relu,例如:

def lrelu(x, alpha):
  return tf.nn.relu(x) - alpha * tf.nn.relu(-x)
Run Code Online (Sandbox Code Playgroud)

编辑

Tensorflow 1.4现在有一个原生的tf.nn.leaky_relu.


Gio*_*kas 7

漏RELU功能已经包含在发布1.4.0-RC1tf.nn.leaky_relu.

文档页面:https://www.tensorflow.org/versions/master/api_docs/python/tf/nn/leaky_relu.