小编Ami*_*min的帖子

如何在 Tensorflow“tf.layers.dense”中使用“leaky_relu”作为激活?

使用Tensorflow 1.5,我想补充leaky_relu活化的致密层的输出,而我能够改变alphaleaky_relu(检查这里)。我知道我可以这样做:

output = tf.layers.dense(input, n_units)
output = tf.nn.leaky_relu(output, alpha=0.01)
Run Code Online (Sandbox Code Playgroud)

我想知道是否有一种方法可以将其写在一行中,因为我们可以这样做relu

ouput = tf.layers.dense(input, n_units, activation=tf.nn.relu)

我尝试了以下操作,但出现错误:

output = tf.layers.dense(input, n_units, activation=tf.nn.leaky_relu(alpha=0.01))
TypeError: leaky_relu() missing 1 required positional argument: 'features'
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

python tensorflow

9
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×1

tensorflow ×1