tf.nn.relu

tf.nn.relu(features, name = None)

 这个函数的作用是计算激活函数 relu,即 max(features, 0)。即将矩阵中每行的非最大值置0。

import tensorflow as tf

a = tf.constant([-1.0, 2.0])
with tf.Session() as sess:
    b = tf.nn.relu(a)
    print sess.run(b)
以上程序输出的结果是:[0. 2.]
posted @ 2018-08-01 14:14  瘋耔  阅读(283)  评论(0编辑  收藏  举报
跳至侧栏