• 技术文章 >Python技术 >Python基础教程

    python Tanh函数如何理解

    小妮浅浅小妮浅浅2021-08-18 09:35:54原创7681

    说明

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

    在数学中,双曲正切Tanh是由基本双曲函数双曲正弦和双曲余弦推导而来。

    2、优点,比Sigmoid函数收敛速度更快、输出以0为中心。缺点,由于饱和性产生的梯度消失。

    实例

    import numpy as np
    import matplotlib.pyplot as plt
    from scipy import special
    x = np.linspace(-100, 100, 1000)
     
    y = np.tanh(x)         #tanh函数
    z = special.expit(x)   #sigmoid函数
     
    plt.figure
    plt.plot(x, y, color = "red", linewidth = 2, label="tanh")
    plt.plot(x, z, color = "b", linewidth = 2, label="sigmoid")
    plt.xlabel("abscissa")
    plt.ylabel("ordinate")
    plt.legend(loc='upper left')
    plt.title("tanh&sigmoid Example")
    plt.show()

    以上就是python Tanh函数的理解,希望对大家有所帮助。更多Python学习指路:python基础教程

    本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

    专题推荐:python tanh函数
    品易云
    上一篇:python中sigmoid函数是什么 下一篇:python ReLU函数是什么

    相关文章推荐

    • python中Box-Cox变换是什么• python中fail函数如何使用• python中yaml文件的使用规则• python中yaml的三种数据结构• python中cookie和session的区别• python HTTP和HTTPS的不同• python有哪些常见的接口测试工具• python函数中参数位置如何传递• python关键字如何传递参数• python参数如何传递默认值• python包裹传递如何使用• python解包裹传递是什么• python混合传递的基本原则• python局部变量是什么• python中sigmoid函数是什么

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网