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

relu的图像是这样的(下载自百度)

 

这样做的目的我目前不清楚。

激活函数的一些介绍

激活函数的百度百科

 

你可能感兴趣的:(tensorflow)