tanh Function

本文对比了两种常用的神经网络激活函数:tanh函数与Sigmoid函数。详细介绍了它们的数学公式及导数,并通过图表直观展示了两者的特性。此外,还提供了tanh函数在Octave中的实现示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

tanh Function

1. Introduction

To limit all data within the range of -1 to 1. Comparing to Sigmoid Function which output range is [0,1]

2. Formula

The formula and derivative of tanh is:

f(z)f(z)=tanh(z)=ezezez+ez=1(f(z))2

where as the sigmoid function is pretty close
f(z)f(z)=sigmoid(z)=11+ez=1f(z)

See the figure of tanh and sigmoid below.
tanh

tanh Function

sigmoid

sigmoid Function

3. Implementation

3.1 Octave

 x = linspace(-10, 10 ,10000);
 y = zeros( size(x, 1), size(x, 2));

 for i = 1:length(x)
   y(i) = 1/(1+e^(-x(i)));
 endfor

 figure();
 plot( x,y);
 grid on;
 xlabel("x");
 ylabel("y=1/(1+e^-x)");
 title("Sigmoid Function");

Output figure
tanh

tanh Function

Relative

Sigmoid Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值