torch.nn.CELU
原型
CLASS torch.nn.CELU(alpha=1.0, inplace=False)
参数
- inplace (bool, optional) – 可选的是否为内部处理. 默认为
False
- alpha (float) –
CELU
公式里的值,默认为1.0
定义
CELU ( x ) = max ( 0 , x ) + min ( 0 , α ∗ ( exp ( x / α ) − 1 ) ) \text{CELU}(x)=\max(0,x)+\min(0, \alpha∗(\exp(x/\alpha)−1)) CELU(x)=max(0,x)+min(0,α∗(exp(x/α)−1))
图
代码
import torch
import torch.nn as nn
m = nn.CELU()
input = torch.randn(4)
output = m(input)
print("input: ", input) # input: tensor([ 0.1335, 0.9612, -0.3477, -0.5911])
print("output: ", output) # output: tensor([ 0.1335, 0.9612, -0.2937, -0.4463])