当前位置: 首页 > news >正文

【PyTorch】教程:torch.nn.Hardswish

torch.nn.Hardswish

原型

CLASS torch.nn.Hardswish(inplace=False)

参数

  • inplace (bool) – 内部运算,默认为 False

定义

Hardswish(x)={0if x≤−3,xif x≥+3,x⋅(x+3)/6otherwise\text{Hardswish}(x) = \begin{cases} 0 & \text{if~} x \le -3, \\ x & \text{if~} x \ge +3, \\ x \cdot (x + 3) /6 & \text{otherwise} \end{cases} Hardswish(x)=0xx(x+3)/6if x3,if x+3,otherwise

在这里插入图片描述

代码

import torch
import torch.nn as nnm = nn.Hardswish()
input = torch.randn(4)
output = m(input)
print("input: ", input)   # input:  tensor([-0.5567, -0.4911,  0.2918,  2.1492]) 
print("output: ", output) # output:  tensor([-0.2267, -0.2054,  0.1601,  1.8445])

【参考】

Hardswish — PyTorch 1.13 documentation

http://www.lryc.cn/news/33350.html

相关文章:

  • nacos源码入门
  • 【记录】Samba|Windows 11的Samba连接切换用户
  • vue hiprint vue使用hiprint打印控件VUE HiPrint HiPrint简单使用
  • HBase常用Shell命令
  • 【阿里云】Apsara Clouder云计算专项技能认证-云服务器ECS入门,考试真题分享
  • 怎样编写java程序
  • 面向对象设计模式:结构型模式之适配器模式
  • Unity3D Shader系列之模板测试
  • 机器学习中的数学——精确率与召回率
  • Oracle启动数据库报ORA-01102解决办法
  • Go 语言面向对象编程及实践
  • 0102 MySQL05
  • [深入理解SSD系列 闪存2.1.3] 固态硬盘闪存的物理学原理_NAND Flash 的读、写、擦工作原理
  • 洗地机哪家强?洗地机排行榜
  • 【Java基础 下】 029 -- 多线程
  • R语言生物群落(生态)数据统计分析与绘图
  • 浙江首场千人大会现场爆满!实在智能九哥专题演讲:企业数字化转型,从实在RPA开始!
  • Windows 上 执行docker pull命令 提示:The system cannot find the file specified.
  • 查看 WiFi 密码的两种方法
  • 逻辑优化基础-bi-decomposition
  • Modbus转profinet网关连接1200PLC在博图组态与驱动器通讯程序案例
  • Android ART虚拟机 启动和初始化
  • 宇视科技一二三面
  • 优思学院|盘点,精益生产25个工具!【必需收藏】
  • Linux中将多块新硬盘合并成一个,挂载到/mysqldata目录下
  • Git的SSH密钥配置
  • C++回顾(九)——多继承
  • 交流约瑟夫森效应
  • 大数据项目实战之数据仓库:用户行为采集平台——第3章 用户行为日志
  • centos6下为Rstudio安装多版本R