原型
CLASS torch.nn.Softsign()
定义
SoftSign(x)=x1+∣x∣\text{SoftSign}(x)=\frac{x}{1+|x|} SoftSign(x)=1+∣x∣x
图
代码
import torch
import torch.nn as nnm = nn.Softsign()
input = torch.randn(4)
output = m(input)print("input: ", input)
print("output: ", output)# input: tensor([ 0.0046, -0.4135, -2.0152, 1.1037])
# output: tensor([ 0.0046, -0.2925, -0.6683, 0.5246])
Softsign — PyTorch 1.13 documentation