tensorflow的tf.nn.relu()函数

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]]

现在懂了吧

猜你喜欢

转载自blog.csdn.net/random_r/article/details/80523265
今日推荐