Keras 中有leaky_relu的实现。leaky_relu被整合进了relu函数。
参考官方文档:

https://tensorflow.google.cn/api_docs/python/tf/keras/backend/relu?hl=en

Arguments
x A tensor or variable.
alpha A scalar, slope of negative section (default=0.).
max_value float. Saturation threshold.
threshold float. Threshold value for thresholded activation.

alpha(超参数)值控制负数部分线性函数的梯度。当alpha = 0 ,是原始的relu函数。当alpha >0,即为leaky_relu。

查看源码,在Keras.backbend 中,也是调用tensorflow.python.ops库nn中的leaky_relu函数实现的:

def relu(x, alpha=0., max_value=None, threshold=0):"""Rectified linear unit.With default values, it returns element-wise `max(x, 0)`.Otherwise, it follows:`f(x) = max_value` for `x >= max_value`,`f(x) = x` for `threshold <= x < max_value`,`f(x) = alpha * (x - threshold)` otherwise.Arguments:x: A tensor or variable.alpha: A scalar, slope of negative section (default=`0.`).max_value: float. Saturation threshold.threshold: float. Threshold value for thresholded activation.Returns:A tensor."""if alpha != 0.:if max_value is None and threshold == 0:return nn.leaky_relu(x, alpha=alpha)    ##在这里调用了leaky_reluif threshold != 0:negative_part = nn.relu(-x + threshold)else:negative_part = nn.relu(-x)clip_max = max_value is not Noneif threshold != 0:# computes x for x > threshold else 0x = x * math_ops.cast(math_ops.greater(x, threshold), floatx())elif max_value == 6:# if no threshold, then can use nn.relu6 native TF op for performancex = nn.relu6(x)clip_max = Falseelse:x = nn.relu(x)if clip_max:max_value = _constant_to_tensor(max_value, x.dtype.base_dtype)zero = _constant_to_tensor(0, x.dtype.base_dtype)x = clip_ops.clip_by_value(x, zero, max_value)if alpha != 0.:alpha = _to_tensor(alpha, x.dtype.base_dtype)x -= alpha * negative_partreturn x

Keras 调用leaky_relu相关推荐

  1. [Keras] 使用Keras调用多GPU时出现无法保存模型的解决方法

    在使用keras 的并行多路GPU时出现了模型无法 保存,在使用单个GPU时运行完全没有问题.运行出现can't pickle的问题 随后在网上找了很多解决方法.下面列举一些我实验成功的方法. 方法一 ...

  2. Keras使用Leaky_Relu等高级激活函数

    在Keras中,Leaky_Relu等高级激活函数需要通过额外增加层来使用,而不能像RELU之类的激活函数可以作为参数初始化全连接层. 具体用法如下: from keras.layers import ...

  3. Keras调用model.load_weights时报错

    报错:ValueError: Unable to load weights saved in HDF5 format into a subclassed Model which has not cre ...

  4. 【Keras学习】常见问题与解答

    Keras FAQ:常见问题 如何引用Keras? 如果Keras对你的研究有帮助的话,请在你的文章中引用Keras.这里是一个使用BibTex的例子 @misc{chollet2015keras,a ...

  5. 学习笔记 Keras:常见问题

    目录: 目录: 常见问题 如何引用Keras? 如何使Keras调用GPU? 如何在多张GPU卡上使用Keras? 数据并行 设备并行 "batch", "epoch&q ...

  6. 当Bert遇上Keras:这可能是Bert最简单的打开姿势

    作者丨苏剑林 研究方向丨NLP,神经网络 个人主页丨kexue.fm Bert 是什么,估计也不用笔者来诸多介绍了.虽然笔者不是很喜欢Bert,但不得不说,Bert 确实在 NLP 界引起了一阵轩然大 ...

  7. [深度学习] Keras 如何使用fit和fit_generator

    介绍 在本教程中,您将了解Keras .fit和.fit_generator函数的工作原理,包括它们之间的差异.为了帮助您获得实践经验,我已经提供了一个完整的示例,向您展示如何从头开始实现Keras数 ...

  8. java 调用gpu_GPU使用设置

    keras参考资料:https://keras.io/zh/getting-started/faq/#sample-batch-epoch https://keras-cn.readthedocs.i ...

  9. 纵观Tensorflow、Keras、Pytorch的发展史

    Tensorflow的发展历史: 2015年9月发布0.1版本 2017年2月发布0.1版本 2019年春发布2.0版本(2.0beta) 与tensorflow同时期出来的框架 Scikit-lea ...

最新文章

  1. 没有统计学基础可以学python-没错!经典教材《统计学习导论》现在有了 Python版!...
  2. global cache cr request
  3. vivado2017.4安装教程
  4. Python数值类型:小数与百分数的转换
  5. 五款帮助创业者迅速熟悉互联网创业的在线学习工具
  6. C# 通过ImportNode AppendChild方法合并XmlDocument,XML转为DataTable
  7. eigen冲突 sophus 安装_SLAM-Sophus模板库安装总结
  8. Highcharts:小案例,自定义图片下载路径,中文乱码的解决办法(不足之处,求指点)。...
  9. 黄金分割比的重新理解
  10. HTML实现页面注册
  11. dspemif怎么读_DSP技术在EMIF接口中的BOOT方法简析
  12. 中科大一所学校撑起中国人工智能半壁江山
  13. 将路由器作为AP来使用
  14. 按“window+E”键出现【找不到应用程序】或【explore.exe找不到】的解决方法
  15. 【程序员必修数学课】-基础思想篇-二进制-原码反码补码的数学论证
  16. Balsamiq Mockups 产品原型图绘制工具的破解和使用教程
  17. 【数据挖掘】任务4:20Newsgroups聚类
  18. 牛市源码定制,抖音矩阵系统源头开发,here
  19. labview中java联合编程_LabVIEW与MATLAB混合编程的实现
  20. Python爬虫的源码

热门文章

  1. HTML与CSS进阶
  2. 关于去除小论文中最后一页后面的空白页
  3. Python—— 输出换行运用
  4. 用python实现简单的2D游戏
  5. 梦在远方路在脚下,社科院与杜兰大学金融管理硕士项目与你一路相伴
  6. 过程参数检测及仪表课程设计-第二类标准节流装置设计命题
  7. SAP重置公司代码业务数据和主数据-OBR1/OBR2/OBR3
  8. C++实现线性方程组运算函数 LDL法
  9. WIZnet正式发布W5500
  10. 最新安卓集成环信SDK3.5.1步骤详解大白菜版本,记录下