【PyTorch】教程:torch.nn.ELU

torch.nn.ELU

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

paper: Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs).

参数

  • alpha ([float]) – α \alpha α 默认为1.0
  • inplace ([bool] ) – 内部做, 默认为 False

ELU 定义

ELU ( x ) = { x ,  if  x > 0 α ∗ ( exp ⁡ ( x ) − 1 ) ,  if  x ≤ 0 \text{ELU}(x) = \begin{cases} x, & \text{ if } x > 0\\ \alpha * (\exp(x) - 1), & \text{ if } x \leq 0 \end{cases} ELU(x)={ x,α(exp(x)1), if x>0 if x0

在这里插入图片描述

代码

import torch
import torch.nn as nn
m = nn.ELU()
input = torch.randn(2)
output = m(input)
print("input: ", input)  # input:  tensor([-2.2888,  1.2803])
print("output: ", output) # output:  tensor([-0.8986,  1.2803])

【参考】

ELU — PyTorch 1.13 documentation

猜你喜欢

转载自blog.csdn.net/zhoujinwang/article/details/129290502