tensorflow tanh应用
Posted debuggor
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tensorflow tanh应用相关的知识,希望对你有一定的参考价值。
1、tanh()函数
tanh是双曲函数中的一个,tanh()为双曲正切。
双曲正切函数的导数公式:
![](https://gss3.bdstatic.com/-Po3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D214/sign=d75f12b3ecf81a4c2232ebc8e32b6029/77094b36acaf2edd78a0e92e8a1001e9380193a0.jpg)
![](https://image.cha138.com/20210608/17336fe181864644b1a3ea5613a64de2.jpg)
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]
以上是关于tensorflow tanh应用的主要内容,如果未能解决你的问题,请参考以下文章
tensorflow学习-------激活函数(activation function)