【PyTorch】教程:torch.nn.Softshrink
torch.nn.Softshrink
原型
CLASS torch.nn.Softshrink(lambd=0.5)
参数
- lambd (float) – λ \lambda λ 为 Softshrink参数,默认为 0.5, 必须不小于0
定义
SoftShrinkage ( x ) = { x − λ , if x > λ x + λ , if x < − λ 0 , otherwise \text{SoftShrinkage}(x)=\begin{cases} x-\lambda, & \text{if } x > \lambda \\ x+\lambda, & \text{if } x < -\lambda \\ 0, & \text{otherwise} \end{cases} SoftShrinkage(x)=⎩ ⎨ ⎧x−λ,x+λ,0,if x>λif x<−λotherwise
图
代码
import torch
import torch.nn as nn
m = nn.Softshrink()
input = torch.randn(4)
output = m(input)
print("input: ", input)
print("output: ", output)
# input: tensor([ 0.9876, -2.0183, -0.7573, -1.7960])
# output: tensor([ 0.4876, -1.5183, -0.2573, -1.2960])
【参考】
相关文章
- SQLite使用教程10 运算符
- 最详细在Windows安装Xamarin.iOS教程
- 【PyTorch】教程:torch.nn.SiLU
- 【PyTorch】教程:torch.nn.Sigmoid
- 【PyTorch】教程:torch.nn.GELU
- 【PyTorch】教程:torch.nn.CELU
- 【PyTorch】教程:torch.nn.RReLU
- 【PyTorch】教程:torch.nn.Hardshrink
- 【PyTorch】教程:torch.nn.ModuleDict
- 【PyTorch】教程:torch.nn.ModuleList
- 【PyTorch】教程:torch.nn.Sequential
- 【PyTorch】教程:可视化数据,模型和训练过程
- 【PyTorch】教程:学习基础知识-(8) 保存和加载模型
- 最全Pycharm教程(37)——Pycharm版本号控制之基础篇
- 【ClickHouse 极简教程】分布式下的 IN/JOIN 及 GLOBAL关键字
- kotlin极简教程 高阶函数 函数式编程章节节选
- 真正菜鸟用教程之WQSG Scrip Export WQSG (脚本导出导入工具,PSP、NDS汉化必备 )
- 计算机视觉最全方向专栏教程总结
- SPSS连接mysql数据库详细操作教程
- 超简单的pytorch(GPU版)安装教程(亲测有效)