tf.nn.relu()函数是将大于0的数保持不变,小于0的数置为0
import tensorflow as tf a = tf.constant([-2,-1,0,2,3]) with tf.Session() as sess: print(sess.run(tf.nn.relu(a)))
结果是
[0 0 0 2 3]
又如
import tensorflow as tf a = tf.constant([[-2,-4],[4,-2]]) with tf.Session() as sess: print(sess.run(tf.nn.relu(a)))
输出结果为
[[0 0] [4 0]]
现在懂了吧