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

【PyTorch】教程:torch.nn.LeakyReLU

torch.nn.LeakyReLU

原型

CLASS torch.nn.LeakyReLU(negative_slope=0.01, inplace=False)

参数

  • negative_slope (float) – 控制负值斜率,默认为 1e-2
  • inplace (bool) – in-place 操作,默认为 False

定义

LeakyReLU(x)=max⁡(0,x)+negative_slope∗min⁡(0,x)\text{LeakyReLU}(x) = \max(0, x) + \text{negative\_slope} * \min(0, x) LeakyReLU(x)=max(0,x)+negative_slopemin(0,x)

or

LeakyReLU(x)={x,if x≥0negative_slope×x,otherwise \text{LeakyReLU}(x) = \begin{cases} x, & \text{ if } x \geq 0 \\ \text{negative\_slope} \times x, & \text{ otherwise } \end{cases} LeakyReLU(x)={x,negative_slope×x, if x0 otherwise 

在这里插入图片描述

代码

import torch
import torch.nn as nnm = nn.LeakyReLU(0.1)
input = torch.randn(2)
output = m(input)print("input: ", input)    # input:  tensor([-1.5754,  0.6229])
print("output: ", output)  # output:  tensor([-0.1575,  0.6229])

【参考】

LeakyReLU — PyTorch 1.13 documentation

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

相关文章:

  • 【刷题】-- 基础 -- 二分查找
  • Spark MLlib 特征工程
  • CentOS7 完全卸载 php
  • 关于OCS认证里必须知晓的内容
  • 创业做电商难不难?新人做电商怎么才能挣钱?
  • 【项目设计】高并发内存池(七)[性能测试和提升]
  • PHP:Laravel cast array json数据存数据库时unicode 编码问题和update更新不触发数据转换
  • 自动化测试总结--断言
  • 传输线的物理基础(三):传输线的瞬时阻抗
  • 第六章:多线程
  • 铁路与公路
  • GitHub Copilot 全新升级,工作效率提升 55%
  • 【IoT】《天道》中音响案例的SWOT分析
  • 如何实现接口幂等性
  • 相恨见晚的office办公神器(不坑盒子/打工人Excel插件2023年最新版)
  • matlab基础到实战(1)
  • 谷歌发布编写分布式应用的框架Service Weaver
  • 详解FPGA:人工智能时代的驱动引擎观后感
  • Rest/Restful接口
  • 【vue init】三.项目引入axios、申明全局变量、设置跨域
  • 搭建nextcloud私有云盘
  • 05 | 如何安全、快速地接入OAuth 2.0?
  • nest.js学习笔记(一)
  • win下载配置CIC Flowmeter环境并提取流量特征
  • 【LeetCode刷题-Java/Python】二分查找
  • Linux 6.2 已正式发布
  • Kubernetes 101,第一部分,基础知识
  • 企业级信息系统开发学习笔记1.7 基于XML配置方式使用Spring MVC
  • java反射,动态代理
  • React(六):Redux的使用、react-redux简化代码、redux模块化、RTK的使用