tensorflow tanh应用

1、tanh()函数

tanh是双曲函数中的一个,tanh()为双曲正切。

 

双曲正切函数的导数公式:
 

 

2、tensorflow tanh()例子

import tensorflow as tf

input=tf.constant([1,2,3,4],dtype=tf.float32)
#在tensorflow1.2中tf.nn.tanh和tf.tanh都可以
#output=tf.nn.tanh(input)
output=tf.tanh(input)
with tf.Session() as sess:
    print(sess.run(output))
    sess.close()

输出结果:

[ 0.76159418  0.96402758  0.99505472  0.99932921]

posted @ 2017-07-22 00:38  debuggor  阅读(1315)  评论(0编辑  收藏  举报