tensorflow tanh应用
1、tanh()函数
tanh是双曲函数中的一个,tanh()为双曲正切。
双曲正切函数的导数公式:
![](https://gss3.bdstatic.com/-Po3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D214/sign=d75f12b3ecf81a4c2232ebc8e32b6029/77094b36acaf2edd78a0e92e8a1001e9380193a0.jpg)
![](https://images2015.cnblogs.com/blog/1204043/201707/1204043-20170722003500074-2061860836.png)
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]