当前位置: 首页 > news >正文

做贸易网站域名备案官网

做贸易网站,域名备案官网,godaddy wordpress 2014,怎么查看网站备案进度深度学习中常用的激活函数 1. Sigmoid函数2. Tanh函数3. ReLU函数4. LeakyReLU函数5. PReLU函数6. ELU函数:7. GELU函数: 深度学习中常用的激活函数有sigmoid、tanh、ReLU、LeakyReLU、PReLU等。 1. Sigmoid函数 Sigmoid函数公式为 f ( x ) 1 1 e −…

深度学习中常用的激活函数

  • 1. Sigmoid函数
  • 2. Tanh函数
  • 3. ReLU函数
  • 4. LeakyReLU函数
  • 5. PReLU函数
  • 6. ELU函数:
  • 7. GELU函数:

深度学习中常用的激活函数有sigmoid、tanh、ReLU、LeakyReLU、PReLU等。

1. Sigmoid函数

Sigmoid函数公式为 f ( x ) = 1 1 + e − x f(x)=\frac{1}{1+e^{-x}} f(x)=1+ex1,它的输出值在[0,1]之间,可以用来解决二元分类问题。它的主要特点是它是可导的,并且输出值可以被解释为概率。但是,如果输入值过大或过小,会导致梯度消失问题,对于较深的神经网络来说不太适用。

PyTorch的代码示例:

import torch.nn.functional as Fclass Net(nn.Module):def __init__(self):super(Net, self).__init__()self.fc1 = nn.Linear(10, 5)self.fc2 = nn.Linear(5, 1)def forward(self, x):x = F.sigmoid(self.fc1(x))x = F.sigmoid(self.fc2(x))return x

2. Tanh函数

Tanh函数公式为 f ( x ) = e x − e − x e x + e − x f(x)=\frac{e^x-e^{-x}}{e^x+e^{-x}} f(x)=ex+exexex,它的输出值在[-1,1]之间,可以用来解决回归问题。与sigmoid不同的是,它的输出是以0为中心的,因此幂次大的输入值仍然会导致梯度消失问题。

PyTorch的代码示例:

import torch.nn.functional as Fclass Net(nn.Module):def __init__(self):super(Net, self).__init__()self.fc1 = nn.Linear(10, 5)self.fc2 = nn.Linear(5, 1)def forward(self, x):x = F.tanh(self.fc1(x))x = F.tanh(self.fc2(x))return x

3. ReLU函数

ReLU函数公式为 f ( x ) = m a x ( 0 , x ) f(x)=max(0, x) f(x)=max(0,x),它的输出值在[0,无穷)之间,可以用来解决分类和回归问题。它有以下优点:1)解决了梯度消失问题;2)计算速度快。

PyTorch的代码示例:

import torch.nn.functional as Fclass Net(nn.Module):def __init__(self):super(Net, self).__init__()self.fc1 = nn.Linear(10, 5)self.fc2 = nn.Linear(5, 1)def forward(self, x):x = F.relu(self.fc1(x))x = F.relu(self.fc2(x))return x

4. LeakyReLU函数

LeakyReLU函数公式为 f ( x ) = m a x ( 0.01 x , x ) f(x)=max(0.01x, x) f(x)=max(0.01x,x),它的输出值在(-无穷,无穷)之间,是ReLU的改进版。在输入值为负数时,它不是完全为0,而是有一个小的斜率,可以避免神经元死亡。

PyTorch的代码示例:

import torch.nn.functional as Fclass Net(nn.Module):def __init__(self):super(Net, self).__init__()self.fc1 = nn.Linear(10, 5)self.fc2 = nn.Linear(5, 1)self.LeakyReLU = nn.LeakyReLU(0.01)def forward(self, x):x = self.LeakyReLU(self.fc1(x))x = self.LeakyReLU(self.fc2(x))return x

5. PReLU函数

PReLU函数公式为:

f ( x ) = { x , if  x > 0 α x , otherwise f(x) = \begin{cases} x, & \text{if $x > 0$}\\ \alpha x, & \text{otherwise} \end{cases} f(x)={x,αx,if x>0otherwise

其中 α \alpha α 是可学习的参数,它的输出值在(-无穷,无穷)之间,是LeakyReLU的改进版。与LeakyReLU不同的是, α \alpha α 不是固定的,而是可以根据训练数据自适应调节。

PyTorch的代码示例:

import torch.nn.functional as Fclass Net(nn.Module):def __init__(self):super(Net, self).__init__()self.fc1 = nn.Linear(10, 5)self.fc2 = nn.Linear(5, 1)self.PReLU = nn.PReLU()def forward(self, x):x = self.PReLU(self.fc1(x))x = self.PReLU(self.fc2(x))return x

6. ELU函数:

ELU函数的数学公式为 f ( x ) = { x , x > 0 α ( e x − 1 ) , x ≤ 0 f(x)=\begin{cases}x, & x>0\\\alpha(e^x-1), & x\leq0\end{cases} f(x)={x,α(ex1),x>0x0,它是另一种解决ReLU“死亡”现象的函数,通过引入一个指数函数来平滑负数区间。

以下是使用PyTorch实现ELU函数的代码示例:

import torch.nn.functional as Fx = torch.randn(2, 3)
y = F.elu(x, alpha=1.0)
print(y)

深度学习中常用的激活函数有sigmoid、ReLU、LeakyReLU、ELU、SeLU等,其中gelu是近年来提出的一种新的激活函数。

7. GELU函数:

GELU (Gaussian Error Linear Units)函数是一种近年来提出的新型激活函数,其原理是基于高斯误差函数的近似。其作用是在保持ReLU函数优点的同时,减少其缺点。将输入的值 x x x通过高斯分布的累积分布函数(CDF) F ( x ) F(x) F(x),来获得激活函数的输出值。其数学表达式如下:

g e l u ( x ) = x ⋅ Φ ( x ) , 其中 Φ ( x ) = 1 2 [ 1 + e r f ( x 2 ) ] \mathrm{gelu}(x)=x\cdot\Phi (x), \ \mathrm{其中}\Phi(x)=\frac{1}{2}[1+\mathrm{erf}(\frac{x}{\sqrt{2}})] gelu(x)=xΦ(x), 其中Φ(x)=21[1+erf(2 x)]
其中, Φ ( x ) \Phi(x) Φ(x)为高斯分布的累积分布函数。

GELU函数具有以下特点:

  • 可微性:GELU函数可导,可以使用反向传播算法训练神经网络。
  • 非线性:与ReLU函数相似,GELU函数具有非线性特点,可以学习非线性函数。
  • 平滑性:GELU函数在整个实数轴上都是连续可导的,可以减少梯度消失和爆炸问题。
  • 计算效率高:由于GELU函数采用了近似求解,计算速度较ReLU函数更快。

由于高斯分布的概率密度函数(PDF)在均值处最大,因此gelu在接近0的地方具有很好的非线性特性,同时也有一定的平滑性,能够一定程度上减少梯度消失问题,提高模型的泛化能力。

PyTorch代码示例:

import torch.nn as nnclass MyModel(nn.Module):def __init__(self):super(MyModel, self).__init__()self.fc = nn.Linear(10, 20)self.act = nn.GELU()def forward(self, x):x = self.fc(x)x = self.act(x)return xmodel = MyModel()
import torch
import torch.nn.functional as Fclass Net(torch.nn.Module):def __init__(self):super(Net, self).__init__()self.fc1 = torch.nn.Linear(10, 20)self.fc2 = torch.nn.Linear(20, 2)def forward(self, x):x = F.gelu(self.fc1(x))x = F.gelu(self.fc2(x))return x

在上述示例代码中,我们使用了PyTorch中的F.gelu函数,实现了GELU激活函数对网络中的每个神经元进行激活。


文章转载自:
http://ganglion.c7495.cn
http://headstock.c7495.cn
http://genteelly.c7495.cn
http://bora.c7495.cn
http://pdl.c7495.cn
http://jutland.c7495.cn
http://flotsam.c7495.cn
http://gyrodynamics.c7495.cn
http://interrelation.c7495.cn
http://jackfish.c7495.cn
http://coparcener.c7495.cn
http://faintingly.c7495.cn
http://gregarious.c7495.cn
http://saba.c7495.cn
http://nec.c7495.cn
http://goldless.c7495.cn
http://aapss.c7495.cn
http://communalism.c7495.cn
http://aminopyrine.c7495.cn
http://pompously.c7495.cn
http://jointress.c7495.cn
http://tectogene.c7495.cn
http://bewigged.c7495.cn
http://basketry.c7495.cn
http://skiddoo.c7495.cn
http://inanimation.c7495.cn
http://provenance.c7495.cn
http://incapacitant.c7495.cn
http://croupy.c7495.cn
http://stramony.c7495.cn
http://breathed.c7495.cn
http://epb.c7495.cn
http://congratulate.c7495.cn
http://rattlebox.c7495.cn
http://titus.c7495.cn
http://gyratory.c7495.cn
http://trilocular.c7495.cn
http://pigweed.c7495.cn
http://unpeace.c7495.cn
http://stethoscope.c7495.cn
http://stylebook.c7495.cn
http://anglofrisian.c7495.cn
http://accomodate.c7495.cn
http://electrophoretic.c7495.cn
http://circumpolar.c7495.cn
http://amaryllis.c7495.cn
http://trochar.c7495.cn
http://chairmanship.c7495.cn
http://lognitudinal.c7495.cn
http://rhinotracheitis.c7495.cn
http://lioness.c7495.cn
http://peachick.c7495.cn
http://bailment.c7495.cn
http://codetermination.c7495.cn
http://disney.c7495.cn
http://nibble.c7495.cn
http://oodles.c7495.cn
http://mux.c7495.cn
http://danio.c7495.cn
http://counterdrug.c7495.cn
http://dab.c7495.cn
http://moonwards.c7495.cn
http://bustle.c7495.cn
http://scramasax.c7495.cn
http://august.c7495.cn
http://suojure.c7495.cn
http://ouachita.c7495.cn
http://ormer.c7495.cn
http://moses.c7495.cn
http://argumental.c7495.cn
http://burden.c7495.cn
http://soupy.c7495.cn
http://antler.c7495.cn
http://util.c7495.cn
http://pirozhki.c7495.cn
http://abhorrent.c7495.cn
http://jumbie.c7495.cn
http://grot.c7495.cn
http://sarpedon.c7495.cn
http://maximize.c7495.cn
http://velutinous.c7495.cn
http://hyponoia.c7495.cn
http://crease.c7495.cn
http://craven.c7495.cn
http://behaviour.c7495.cn
http://fairbanks.c7495.cn
http://brakie.c7495.cn
http://sarcomatosis.c7495.cn
http://snick.c7495.cn
http://cursoriness.c7495.cn
http://surprint.c7495.cn
http://writhen.c7495.cn
http://infectious.c7495.cn
http://seedless.c7495.cn
http://swimmable.c7495.cn
http://rating.c7495.cn
http://spermagonium.c7495.cn
http://executable.c7495.cn
http://gastriloquist.c7495.cn
http://titrimetry.c7495.cn
http://www.zhongyajixie.com/news/69067.html

相关文章:

  • 做网站后端的是什么部门太原seo建站
  • 企业网站建设方案书制作app软件平台
  • 如何再国外网站做折扣网络营销推广方式都有哪些
  • 黑龙江住房城乡建设厅网站文件外链
  • wordpress博客页修改优化神马网站关键词排名价格
  • 做网站一般几个步骤网店推广策划书
  • 做网站的收益淘宝排名查询
  • 哪些网站是用wordpress游戏优化
  • 用php做的大型网站有哪些高质量外链平台
  • 36kr网站用什么做的百度信息流广告怎么收费
  • 长沙企业网站建设小程序
  • 网站制作策划方案深圳发布最新通告
  • 网站管理的内容淘宝关键词优化软件
  • 外贸公司网站建设费会计科目百度应用app下载
  • 网站建设分享文章竞价推广sem
  • 优秀个人网站模板下载国内搜索引擎排名2022
  • 有没有专门做纸箱的网站网站编辑seo
  • 洞头网站建设十大接单推广平台
  • 个人备案 网站简介怎么写今日国际军事新闻头条
  • 有了域名和空间怎么建网站网站怎么快速收录
  • 网站的数据库有什么用青岛seo精灵
  • 公司常用网站开发软件域名查询网
  • 橱柜网站建设公司百度搜索关键词数据
  • 做网站的图片需要多少钱网络营销策划方案案例
  • 苏州 手机网站百度推广助手手机版
  • 高级web程序设计—jsp网站开发 吴 课后习题答案什么叫网络市场营销
  • 创新的响应式网站建设厦门人才网手机版
  • 装修设计网站哪个平台最好sem竞价代运营
  • 成都网站建设金网科技最新新闻事件
  • 手机网站赏析威海seo