@@ -45,7 +45,7 @@ relu(x::Real) = max(zero(x), x)
45
45
46
46
47
47
"""
48
- leakyrelu(x) = max(0.01x , x)
48
+ leakyrelu(x, a=0.01 ) = max(a*x , x)
49
49
50
50
Leaky [Rectified Linear Unit](https://en.wikipedia.org/wiki/Rectifier_(neural_networks))
51
51
activation function.
@@ -54,40 +54,41 @@ You can also specify the coefficient explicitly, e.g. `leakyrelu(x, 0.01)`.
54
54
leakyrelu (x:: Real , a = oftype (x / 1 , 0.01 )) = max (a * x, x / one (x))
55
55
56
56
"""
57
- relu6(x) = min(max(0, x),6)
57
+ relu6(x) = min(max(0, x), 6)
58
58
59
59
[Rectified Linear Unit](https://en.wikipedia.org/wiki/Rectifier_(neural_networks))
60
- activation function.
60
+ activation function capped at 6.
61
+ See [Convolutional Deep Belief Networks on CIFAR-10](http://www.cs.utoronto.ca/%7Ekriz/conv-cifar10-aug2010.pdf)
61
62
"""
62
- relu6 (x:: Real ) = min (relu (x), one (x) * oftype (x, 6 ))
63
+ relu6 (x:: Real ) = min (relu (x), oftype (x, 6 ))
63
64
64
65
"""
65
- rrelu(x) = max(ax , x)
66
+ rrelu(x, l=1/8, u=1/3 ) = max(a*x , x)
66
67
67
- a = randomly sampled from uniform distribution U(l,u)
68
+ a = randomly sampled from uniform distribution U(l, u)
68
69
69
70
Randomized Leaky [Rectified Linear Unit](https://arxiv.org/pdf/1505.00853.pdf)
70
71
activation function.
71
72
You can also specify the bound explicitly, e.g. `rrelu(x, 0.0, 1.0)`.
72
73
"""
73
74
function rrelu (x:: Real , l:: Real = 1 / 8.0 , u:: Real = 1 / 3.0 )
74
- a = oftype (x / 1 , (u - l) * rand () + l)
75
+ a = oftype (x / 1 , (u - l) * rand () + l)
75
76
return leakyrelu (x, a)
76
77
end
77
78
78
79
"""
79
- elu(x, α = 1) =
80
+ elu(x, α= 1) =
80
81
x > 0 ? x : α * (exp(x) - 1)
81
82
82
83
Exponential Linear Unit activation function.
83
84
See [Fast and Accurate Deep Network Learning by Exponential Linear Units](https://arxiv.org/abs/1511.07289).
84
85
You can also specify the coefficient explicitly, e.g. `elu(x, 1)`.
85
86
"""
86
- elu (x, α = one (x)) = ifelse (x ≥ 0 , x / one (x), α * (exp (x) - one (x)))
87
+ elu (x:: Real , α = one (x)) = ifelse (x ≥ 0 , x / one (x), α * (exp (x) - one (x)))
87
88
88
89
89
90
"""
90
- gelu(x) = 0.5x* (1 + tanh(√(2/π)* (x + 0.044715x^3)))
91
+ gelu(x) = 0.5x * (1 + tanh(√(2/π) * (x + 0.044715x^3)))
91
92
92
93
[Gaussian Error Linear Unit](https://arxiv.org/pdf/1606.08415.pdf)
93
94
activation function.
@@ -125,7 +126,8 @@ function selu(x::Real)
125
126
end
126
127
127
128
"""
128
- celu(x) = (x ≥ 0 ? x : α * (exp(x/α) - 1))
129
+ celu(x, α=1) =
130
+ (x ≥ 0 ? x : α * (exp(x/α) - 1))
129
131
130
132
Continuously Differentiable Exponential Linear Units
131
133
See [Continuously Differentiable Exponential Linear Units](https://arxiv.org/pdf/1704.07483.pdf).
@@ -155,7 +157,7 @@ softplus(x::Real) = ifelse(x > 0, x + log1p(exp(-x)), log1p(exp(x)))
155
157
156
158
Return `log(cosh(x))` which is computed in a numerically stable way.
157
159
"""
158
- logcosh (x:: T ) where T = x + softplus (- 2 x) - log (convert (T , 2 ))
160
+ logcosh (x:: Real ) = x + softplus (- 2 x) - log (oftype (x , 2 ))
159
161
160
162
161
163
"""
@@ -174,7 +176,8 @@ See [Tanhshrink Activation Function](https://www.gabormelli.com/RKB/Tanhshrink_A
174
176
tanhshrink (x:: Real ) = x - tanh (x)
175
177
176
178
"""
177
- softshrink = (x ≥ λ ? x-λ : (-λ ≥ x ? x+λ : 0))
179
+ softshrink(x, λ=0.5) =
180
+ (x ≥ λ ? x - λ : (-λ ≥ x ? x + λ : 0))
178
181
179
182
See [Softshrink Activation Function](https://www.gabormelli.com/RKB/Softshrink_Activation_Function)
180
183
"""
0 commit comments