TF-激活函数 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.]

猜你喜欢

转载自www.cnblogs.com/xh_chiang/p/9132524.html