当前位置:网站首页 > Haskell函数式编程 > 正文

sigmoid 函数(sigmoid函数和tanh函数)

以下是使用Python绘制5种常见

激活函数

的图的代码

 import numpy as np import matplotlib.pyplot as plt  # Sigmoid 激活函数 def sigmoid (x): return 1 / (1 + np.exp(-x))  # tanh 激活函数 def tanh (x): return np. tanh (x)  # Re LU 激活函数 def re lu (x): return np.maximum(0, x)  # Leaky Re LU 激活函数 def leaky_re lu (x, alpha=0.01): return np.maximum(alpha * x, x)  # E LU 激活函数 def e lu (x, alpha=1.0): return np.where(x > 0, x, alpha * (np.exp(x) - 1))  # 生成 x 值 x = np.linspace(-10, 10, 100)  # 绘制 激活函数 图像 plt.figure(figsize=(10, 6)) plt.plot(x, sigmoid (x), label=' Sigmoid ') plt.plot(x, tanh (x), label=' tanh ') plt.plot(x, re lu (x), label='Re LU ') plt.plot(x, leaky_re lu (x), label='Leaky Re LU ') plt.plot(x, e lu (x), label='E LU ') plt.xlabel('x') plt.ylabel('Activation') plt.title('Activation Functions') plt.legend() plt.grid(True) plt.show() 

希望这个代码可以帮助你绘制出

Sigmoid

tanh

、Re

LU

、Leaky Re

LU

和E

LU 激活函数

的图像。

到此这篇sigmoid 函数(sigmoid函数和tanh函数)的文章就 介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • 字符串转成int类型(字符串转成int类型的函数)2025-04-18 15:00:04
  • 一级写文章,高手如何拟标题?向上概括主题,向下分解演绎二级写文章,高手如何拟标题?向上概括主题,向下分解演绎格式示范(一级写文章,高手如何拟标题?向上概括主题,向下分解演绎二级写文章,高手如何拟标题?向上概括主题,向下分解演绎内容)2025-04-18 15:00:04
  • 报文格式化错误怎么解决(报文格式化错误,请稍后检查账户余额)2025-04-18 15:00:04
  • modbus报文格式和4x的关系(modbus485报文解析)2025-04-18 15:00:04
  • 服务器部署方式集群主备(服务器集中部署)2025-04-18 15:00:04
  • max30102工作原理公式(max30100原理图)2025-04-18 15:00:04
  • 指数与对数的转换公式e(指数与对数的转换公式ln)2025-04-18 15:00:04
  • sigmoid和tanh函数(sigmoid和tanh函数图像)2025-04-18 15:00:04
  • sigmrnd函数(sigmond函数)2025-04-18 15:00:04
  • 窗口函数row_number(窗口函数rank()和dense rank()的区别)2025-04-18 15:00:04
  • 全屏图片