keras代码阅读-relu函数
来源:互联网 发布:linux中的chown命令 编辑:程序博客网 时间:2024/05/15 21:48
概述
relu是激活函数的一种。很多地方说relu函数的公式就是:
阅读了theano的代码
def relu(x, alpha=0): """ Compute the element-wise rectified linear activation function. .. versionadded:: 0.7.1 Parameters ---------- x : symbolic tensor Tensor to compute the activation function for. alpha : scalar or tensor, optional Slope for negative input, usually between 0 and 1. The default value of 0 will lead to the standard rectifier, 1 will lead to a linear activation function, and any value in between will give a leaky rectifier. A shared variable (broadcastable against `x`) will result in a parameterized rectifier with learnable slope(s). Returns ------- symbolic tensor Element-wise rectifier applied to `x`. Notes ----- This is numerically equivalent to ``T.switch(x > 0, x, alpha * x)`` (or ``T.maximum(x, alpha * x)`` for ``alpha < 1``), but uses a faster formulation or an optimized Op, so we encourage to use this function. """ # This is probably the fastest implementation for GPUs. Both the forward # pass and the gradient get compiled into a single GpuElemwise call. # TODO: Check if it's optimal for CPU as well; add an "if" clause if not. # TODO: Check if there's a faster way for the gradient; create an Op if so. if alpha == 0: return 0.5 * (x + abs(x)) else: f1 = 0.5 * (1 + alpha) f2 = 0.5 * (1 - alpha) return f1 * x + f2 * abs(x)
发现这个代码中用了以下方法,当alpha为0的时候
当alpha不等于0时。是这样的:
0 0
- keras代码阅读-relu函数
- keras代码阅读-Activition层
- python绘制神经网络中的ReLU激活函数图像(附代码)
- RELU函数理解
- ReLU函数简介
- sigmoid与ReLU函数
- Relu函数作用
- ReLu激活函数
- ReLu激活函数
- 激活函数-ReLU
- 激活函数-relu
- Keras源代码阅读-Dropout
- 【Tensorflow】tf.nn.relu函数
- 神经网络回顾-Relu激活函数
- 采用ReLU作为激活函数的简单深度神经网络matlab代码设计
- RELU
- sigmod函数tanh函数ReLU函数
- 人工神经网络之激活函数 -RELU函数
- 使用jackson 进行json字符串转java bean报错
- Container With Most Water (容器中盛最多的水)
- DNS解析过程
- JAVA——多线程举例
- 母函数理论知识(学习)
- keras代码阅读-relu函数
- 能模仿韩寒小四写作的神奇循环神经网络
- (4.6.11.3)告别编译运行:Instant Run ---- Android Studio 2.0 Preview发布功能
- Android开发之Intent.Action
- unity3d之半透明粒子遮挡问题
- OpenGL教程
- 如何打印一个变量指定部分的字符
- matlab 降维工具
- 3218: a + b Problem 最小割+主席树优化建图