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

济南建设网站手机百度ai入口

济南建设网站,手机百度ai入口,网站出售,昆明做网站建设有哪些1、nn.ELU 基本语法: class torch.nn.ELU(alpha1.0, inplaceFalse)按元素应用 Exponential Linear Unit (ELU) 函数。 论文中描述的方法:通过指数线性单元 (ELU) 进行快速准确的深度网络学习。 ELU 定义为…

1、nn.ELU

基本语法:

class torch.nn.ELU(alpha=1.0, inplace=False)

按元素应用 Exponential Linear Unit (ELU) 函数。
论文中描述的方法:通过指数线性单元 (ELU) 进行快速准确的深度网络学习。
ELU 定义为:
E L U ( x ) = { x , i f x > 0 α ∗ ( e x p ( x ) − 1 ) , i f x ≤ 0 ELU(x)=\{\begin{array}{c} x, & \mathrm{if~x > 0}\\ \alpha * (exp(x)-1), & \mathrm{if x \le 0} \end{array} ELU(x)={x,α(exp(x)1),if x>0ifx0

Parameters 参数:

  • alpha (float) – ELU 公式的 α α α值。默认值:1.0
  • Inplace(bool) – 可以选择就地执行作。默认值: False

Shape: 形状:

  • Input::(∗),其中 ∗表示任意数量的维度。
  • Output:(∗),与输入的形状相同。

在这里插入图片描述
Examples: 例子:

>>> m = nn.ELU()
>>> input = torch.randn(2)
>>> output = m(input)

2、ReLU

基本语法:

class torch.nn.ReLU(inplace=False)

按元素应用修正的线性单元函数。
R e L U ( x ) = ( x ) + = m a x ( 0 , x ) ReLU(x)=(x)^+=max(0,x) ReLU(x)=(x)+=max(0,x)

Parameters 参数:

  • Inplace (bool) – 可以选择就地执行作。默认值: False

参数说明:

  • inplace=False
import torch
from torch import nnm = nn.ReLU(inplace=False)
input = torch.randn(2)
print(input)
output = m(input)
print(input)
print(output)

此时,输入Input并未改变,而是复制了一份原始输入并在该复制上进行非线性激活:

tensor([ 1.6213, -0.0794])
tensor([ 1.6213, -0.0794])
tensor([1.6213, 0.0000])
  • inplace=True
import torch
from torch import nnm = nn.ReLU(inplace=True)
input = torch.randn(2)
print(input)
output = m(input)
print(input)
print(output)

此时,直接对原始输入数据进行非线性激活:

tensor([-0.3541, -0.6384])
tensor([0., 0.])
tensor([0., 0.])

Shape: 形状:

  • Input: (∗) ,其中 ∗ 表示任意数量的维度。
  • Output: (∗),与输入的形状相同。

在这里插入图片描述
Examples: 例子:

  >>> m = nn.ReLU()>>> input = torch.randn(2)>>> output = m(input)An implementation of CReLU - https://arxiv.org/abs/1603.05201>>> m = nn.ReLU()>>> input = torch.randn(2).unsqueeze(0)>>> output = torch.cat((m(input), m(-input)))

3、Sigmoid

基本语法:

class torch.nn.Sigmoid(*args, **kwargs)

按元素应用 Sigmoid 函数。

S i g m o i d ( x ) = σ ( x ) = 1 1 + e x p ( − x ) Sigmoid(x)=\sigma(x)=\frac{1}{1+exp(-x)} Sigmoid(x)=σ(x)=1+exp(x)1

Shape: 形状:

  • Input: (∗),其中 ∗ 表示任意数量的维度。
  • Output: (∗),与输入的形状相同。

在这里插入图片描述
Examples: 例子:

>>> m = nn.Sigmoid()
>>> input = torch.randn(2)
>>> output = m(input)

4、Tanh

基本语法:

class torch.nn.Tanh(*args, **kwargs)

按元素应用 Hyperbolic Tangent (Tanh) 函数。
T a n h ( x ) = t a n h ( x ) = e x p ( x ) − e x p ( − x ) e x p ( x ) + e x p ( − x ) Tanh(x)=tanh(x)=\frac{exp(x)-exp(-x)}{exp(x)+exp(-x)} Tanh(x)=tanh(x)=exp(x)+exp(x)exp(x)exp(x)

Shape: 形状:

  • Input: (∗),其中 ∗ 表示任意数量的维度。
  • Output: (∗),与输入的形状相同。

在这里插入图片描述
Examples: 例子:

>>> m = nn.Tanh()
>>> input = torch.randn(2)
>>> output = m(input)

5、LeakyReLU

基本语法:

class torch.nn.LeakyReLU(negative_slope=0.01, inplace=False)

按元素应用 LeakyReLU 函数。
L e a k y R e L U ( x ) = m a x ( 0 , x ) + n e g a t i v e s l o p e ∗ m i n ( 0 , x ) LeakyReLU(x)=max(0,x)+negative_slope*min(0,x) LeakyReLU(x)=max(0,x)+negativeslopemin(0,x)
or
L e a k y R e L U ( x ) = { x , i f x ≥ 0 n e g a t i v e s l o p e × x , o t h e r w i s e LeakyReLU(x)=\{\begin{array}{c}x, & \mathrm{if~x\ge0}\\ negative_slope \times x, & \mathrm{otherwise}\end{array} LeakyReLU(x)={x,negativeslope×x,if x0otherwise

Parameters 参数

  • negative_slope(float)– 控制负斜率的角度 (用于负输入值)。默认值:1e-2
  • Inplace (bool)– 可以选择就地执行作。默认值: False

Shape: 形状:

  • 输入: (∗) 其中 * 表示任意数量的附加维度
  • 输出: (∗),与输入形状相同

在这里插入图片描述
Examples: 例子:

>>> m = nn.LeakyReLU(0.1)
>>> input = torch.randn(2)
>>> output = m(input)

5、Softplus

基本语法:

class torch.nn.Softplus(beta=1.0, threshold=20.0)

按元素应用 Softplus 函数。
S o f t p l u s ( x ) = 1 β ∗ log ⁡ ( 1 + e x p ( β ∗ x ) ) Softplus(x)=\frac{1}{\beta}*\log(1+exp(\beta*x)) Softplus(x)=β1log(1+exp(βx))

SoftPlus 是 ReLU 函数的平滑近似值,可用于将机器的输出限制为始终为正。
为了数值稳定性,当 时 i n p u t × β > t h r e s h o l d input×β>threshold input×β>threshold,实现恢复为线性函数。

Parameters 参数

  • beta(float) – Softplus 公式的值 β \beta β。默认值:1
  • threshold(float)– 高于此值的值将恢复为线性函数。默认值:20

参数说明:

  • threshold( β \beta β=1)
    i n p u t × β ≤ t h r e s h o l d input×β \le threshold input×βthreshold时:
import torch
from torch import nnm = nn.Softplus()
input = torch.randn(2)
print(input)output = m(input)
print(output)
tensor([-0.2053,  0.3776])
tensor([0.5958, 0.8997])

可以验证: S o f t p l u s ( − 0.2053 ) = 1 1 ∗ log ⁡ ( 1 + e x p ( 1 ∗ ( − 0.2053 ) ) ) = 0.595756... Softplus(-0.2053)=\frac{1}{1}*\log(1+exp(1*(-0.2053)))=0.595756... Softplus(0.2053)=11log(1+exp(10.2053)))=0.595756...
S o f t p l u s ( 0.3776 ) = 1 1 ∗ log ⁡ ( 1 + e x p ( 1 ∗ ( 0.3776 ) ) ) = 0.899665... Softplus(0.3776)=\frac{1}{1}*\log(1+exp(1*(0.3776)))=0.899665... Softplus(0.3776)=11log(1+exp(10.3776)))=0.899665...

i n p u t × β > t h r e s h o l d input×β > threshold input×β>threshold时:

import torch
from torch import nnm = nn.Softplus()
input = torch.tensor([30.])
print(input)output = m(input)
print(output)
tensor([30.])
tensor([30.])

此时恢复为线性函数

Shape: 形状:

  • Input: (∗) ,其中 ∗ 表示任意数量的维度。
  • Output: (∗) ,与输入的形状相同。

在这里插入图片描述

Examples: 例子:

>>> m = nn.Softplus()
>>> input = torch.randn(2)
>>> output = m(input)
http://www.dtcms.com/wzjs/391339.html

相关文章:

  • 公司做铸造的招聘网站都有哪些广州网站优化
  • 哪个网站的前台背景墙做的好bing搜索引擎
  • 站长工具的使用seo综合查询运营我要恢复百度
  • 辽宁省城乡建设厅官方网站网站建设技术
  • 网站个人备案和企业备案网站引流推广
  • 织梦网站自适应怎么做国际军事最新头条新闻
  • 做论坛网站赚钱吗关键词优化一年的收费标准
  • 做网站用什2020做seo还有出路吗
  • 生态农庄网站模板南京网络优化公司有哪些
  • wordpress2.4在线排名优化
  • 苏州建网站的公司哪家口碑好今天今日头条新闻
  • vue 做门户网站百度学术论文查重官网
  • 网站保留密码 怎么做腰肌劳损的自我治疗和恢复的方法有什么?
  • 南通市住房和建设局网站百度搜索推广多少钱
  • wordpress 网页禁止复制青岛网站seo分析
  • 网站推广经理招聘网站制作平台
  • 高端网站建设专业拓客公司联系方式
  • 做淘宝客没网站百度商家入驻
  • 杭州钱塘区网站建设su搜索引擎优化
  • 品牌推广方式有哪些百度上如何做优化网站
  • 做搜索关键词任务网站百度seo整站优化
  • 做网站 用什么做数据库最好聊城网站推广的公司
  • 网站建设发展状况优化营商环境的意义
  • 北京平台网站建设费用我也要投放广告
  • 免费做手机网站建设网站怎么收录
  • 武汉做装饰公司网站平台竞价恶意点击报案
  • 网站推广教程怎么建网址
  • 网站 建站模式百度广告投放平台叫什么
  • 邢台建设企业网站价格网络推广主要工作内容
  • 大连网站设计开发如何制作一个属于自己的网站