【PyTorch】教程:torch.nn.Softsign

torch.nn.Softsign

原型

CLASS torch.nn.Softsign()

定义

SoftSign ( x ) = x 1 + ∣ x ∣ \text{SoftSign}(x)=\frac{x}{1+|x|} SoftSign(x)=1+xx

在这里插入图片描述

代码

import torch
import torch.nn as nn

m = 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

猜你喜欢

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