天天看點

tensorflow.nn.relu的作用

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

解釋:這個函數的作用是計算激活函數relu,即max(features, 0)。即将矩陣中每行的非最大值置0。

import tensorflow as tf

a = tf.constant([-2.0, 4.0])

with tf.Session() as sess:

b = tf.nn.relu(a)

print (sess.run(b))

以上程式輸出的結果是:[0. 4.]

繼續閱讀