@@ -31,7 +31,7 @@ The ascii name `sigmoid` is also exported.
31
31
32
32
See also [`sigmoid_fast`](@ref).
33
33
34
- ```
34
+ ```julia-repl
35
35
julia> using UnicodePlots
36
36
37
37
julia> lineplot(sigmoid, -5, 5, height=7)
@@ -63,7 +63,7 @@ const sigmoid = σ
63
63
64
64
Piecewise linear approximation of [`sigmoid`](@ref).
65
65
66
- ```
66
+ ```julia-repl
67
67
julia> lineplot(hardsigmoid, -5, 5, height=7)
68
68
┌────────────────────────────────────────┐
69
69
1 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⢀⡠⠖⠋⠉⠉⠉⠉⠉⠉⠉⠉│ hardσ(x)
@@ -102,7 +102,7 @@ const hardsigmoid = hardσ
102
102
103
103
Return `log(σ(x))` which is computed in a numerically stable way.
104
104
105
- ```
105
+ ```julia-repl
106
106
julia> lineplot(logsigmoid, -5, 5, height=7)
107
107
┌────────────────────────────────────────┐
108
108
0 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡧⠤⠔⠒⠒⠒⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉│ logσ(x)
@@ -128,7 +128,7 @@ Segment-wise linear approximation of `tanh`, much cheaper to compute.
128
128
See ["Large Scale Machine Learning"](https://ronan.collobert.com/pub/matos/2004_phdthesis_lip6.pdf).
129
129
130
130
See also [`tanh_fast`](@ref).
131
- ```
131
+ ```julia-repl
132
132
julia> lineplot(hardtanh, -2, 2, height=7)
133
133
┌────────────────────────────────────────┐
134
134
1 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⣀⠔⠋⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉│ hardtanh(x)
@@ -164,7 +164,7 @@ hardtanh(x) = clamp(x, oftype(x, -1), oftype(x, 1)) # clamp(x, -1, 1) is type-s
164
164
[Rectified Linear Unit](https://en.wikipedia.org/wiki/Rectifier_(neural_networks))
165
165
activation function.
166
166
167
- ```
167
+ ```julia-repl
168
168
julia> lineplot(relu, -2, 2, height=7)
169
169
┌────────────────────────────────────────┐
170
170
2 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔⠋│ relu(x)
@@ -188,7 +188,7 @@ Leaky [Rectified Linear Unit](https://en.wikipedia.org/wiki/Rectifier_(neural_ne
188
188
activation function.
189
189
You can also specify the coefficient explicitly, e.g. `leakyrelu(x, 0.01)`.
190
190
191
- ```julia
191
+ ```julia-repl
192
192
julia> lineplot(x -> leakyrelu(x, 0.5), -2, 2, height=7)
193
193
┌────────────────────────────────────────┐
194
194
2 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠒⠉│ #42(x)
@@ -220,7 +220,7 @@ const leakyrelu_a = 0.01 # also used in gradient below
220
220
activation function capped at 6.
221
221
See ["Convolutional Deep Belief Networks"](https://www.cs.toronto.edu/~kriz/conv-cifar10-aug2010.pdf) from CIFAR-10.
222
222
223
- ```
223
+ ```julia-repl
224
224
julia> lineplot(relu6, -10, 10, height=7)
225
225
┌────────────────────────────────────────┐
226
226
6 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠎⠉⠉⠉⠉⠉⠉⠉⠉│ relu6(x)
@@ -245,7 +245,7 @@ Randomized Leaky Rectified Linear Unit activation function.
245
245
See ["Empirical Evaluation of Rectified Activations"](https://arxiv.org/abs/1505.00853)
246
246
You can also specify the bound explicitly, e.g. `rrelu(x, 0.0, 1.0)`.
247
247
248
- ```julia
248
+ ```julia-repl
249
249
julia> lineplot(rrelu, -20, 10, height=7)
250
250
┌────────────────────────────────────────┐
251
251
10 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠖⠋│ rrelu(x)
@@ -275,7 +275,7 @@ Exponential Linear Unit activation function.
275
275
See ["Fast and Accurate Deep Network Learning by Exponential Linear Units"](https://arxiv.org/abs/1511.07289).
276
276
You can also specify the coefficient explicitly, e.g. `elu(x, 1)`.
277
277
278
- ```
278
+ ```julia-repl
279
279
julia> lineplot(elu, -2, 2, height=7)
280
280
┌────────────────────────────────────────┐
281
281
2 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠒⠉│ elu(x)
@@ -305,7 +305,7 @@ deriv_elu(Ω, α=1) = ifelse(Ω ≥ 0, one(Ω), Ω + oftype(Ω, α))
305
305
306
306
Activation function from ["Gaussian Error Linear Units"](https://arxiv.org/abs/1606.08415).
307
307
308
- ```
308
+ ```julia-repl
309
309
julia> lineplot(gelu, -2, 2, height=7)
310
310
┌────────────────────────────────────────┐
311
311
2 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡠⠔⠊│ gelu(x)
363
363
Self-gated activation function.
364
364
See ["Swish: a Self-Gated Activation Function"](https://arxiv.org/abs/1710.05941).
365
365
366
- ```
366
+ ```julia-repl
367
367
julia> lineplot(swish, -2, 2, height=7)
368
368
┌────────────────────────────────────────┐
369
369
2 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤│ swish(x)
@@ -386,7 +386,7 @@ julia> lineplot(swish, -2, 2, height=7)
386
386
Hard-Swish activation function.
387
387
See ["Searching for MobileNetV3"](https://arxiv.org/abs/1905.02244).
388
388
389
- ```
389
+ ```julia-repl
390
390
julia> lineplot(hardswish, -2, 5, height = 7)
391
391
┌────────────────────────────────────────┐
392
392
5 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠔⠒⠉│ hardswish(x)
@@ -430,7 +430,7 @@ deriv_hardswish(x) = ifelse(x < -3, oftf(x,0), ifelse(x > 3, oftf(x,1), x/3 + of
430
430
Activation function from
431
431
["LiSHT: Non-Parametric Linearly Scaled Hyperbolic Tangent ..."](https://arxiv.org/abs/1901.05894)
432
432
433
- ```
433
+ ```julia-repl
434
434
julia> lineplot(lisht, -2, 2, height=7)
435
435
┌────────────────────────────────────────┐
436
436
2 │⠢⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔│ lisht(x)
@@ -469,7 +469,7 @@ lisht(x) = x * tanh_fast(x)
469
469
Scaled exponential linear units.
470
470
See ["Self-Normalizing Neural Networks"](https://arxiv.org/abs/1706.02515).
471
471
472
- ```
472
+ ```julia-repl
473
473
julia> lineplot(selu, -3, 2, height=7)
474
474
┌────────────────────────────────────────┐
475
475
3 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ selu(x)
507
507
508
508
Activation function from ["Continuously Differentiable Exponential Linear Units"](https://arxiv.org/abs/1704.07483).
509
509
510
- ```
510
+ ```julia-repl
511
511
julia> lineplot(celu, -2, 2, height=7)
512
512
┌────────────────────────────────────────┐
513
513
2 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠒⠉│ celu(x)
@@ -535,7 +535,7 @@ deriv_celu(Ω, α=1) = ifelse(Ω > 0, oftf(Ω, 1), Ω / oftf(Ω, α) + 1)
535
535
Threshold gated rectified linear activation function.
536
536
See ["Zero-bias autoencoders and the benefits of co-adapting features"](https://arxiv.org/abs/1402.3337)
537
537
538
- ```
538
+ ```julia-repl
539
539
julia> lineplot(trelu, -2, 4, height=7)
540
540
┌────────────────────────────────────────┐
541
541
4 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠖⠋│ trelu(x)
@@ -559,7 +559,7 @@ const thresholdrelu = trelu
559
559
560
560
See ["Quadratic Polynomials Learn Better Image Features"](http://www.iro.umontreal.ca/~lisa/publications2/index.php/attachments/single/205) (2009).
561
561
562
- ```
562
+ ```julia-repl
563
563
julia> lineplot(softsign, -5, 5, height=7)
564
564
┌────────────────────────────────────────┐
565
565
1 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣀⠤⠤⠤⠤⠤│ softsign(x)
@@ -602,7 +602,7 @@ deriv_softsign(x) = 1 / (1 + abs(x))^2
602
602
603
603
See ["Deep Sparse Rectifier Neural Networks"](http://proceedings.mlr.press/v15/glorot11a/glorot11a.pdf), JMLR 2011.
604
604
605
- ```
605
+ ```julia-repl
606
606
julia> lineplot(softplus, -3, 3, height=7)
607
607
┌────────────────────────────────────────┐
608
608
4 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ softplus(x)
@@ -640,7 +640,7 @@ softplus(x) = log1p(exp(-abs(x))) + relu(x)
640
640
641
641
Return `log(cosh(x))` which is computed in a numerically stable way.
642
642
643
- ```
643
+ ```julia-repl
644
644
julia> lineplot(logcosh, -5, 5, height=7)
645
645
┌────────────────────────────────────────┐
646
646
5 │⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ logcosh(x)
@@ -664,7 +664,7 @@ const log2 = log(2)
664
664
665
665
Activation function from ["Mish: A Self Regularized Non-Monotonic Neural Activation Function"](https://arxiv.org/abs/1908.08681).
666
666
667
- ```
667
+ ```julia-repl
668
668
julia> lineplot(mish, -5, 5, height=7)
669
669
┌────────────────────────────────────────┐
670
670
5 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡠⠖⠋│ mish(x)
@@ -686,7 +686,7 @@ mish(x) = x * tanh(softplus(x))
686
686
687
687
See ["Tanhshrink Activation Function"](https://www.gabormelli.com/RKB/Tanhshrink_Activation_Function).
688
688
689
- ```
689
+ ```julia-repl
690
690
julia> lineplot(tanhshrink, -3, 3, height=7)
691
691
┌────────────────────────────────────────┐
692
692
3 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ tanhshrink(x)
@@ -712,7 +712,7 @@ tanhshrink(x) = x - tanh_fast(x)
712
712
713
713
See ["Softshrink Activation Function"](https://www.gabormelli.com/RKB/Softshrink_Activation_Function).
714
714
715
- ```
715
+ ```julia-repl
716
716
julia> lineplot(softshrink, -2, 2, height=7)
717
717
┌────────────────────────────────────────┐
718
718
2 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀│ softshrink(x)
@@ -770,7 +770,7 @@ For any other number types, it just calls `tanh`.
770
770
771
771
See also [`sigmoid_fast`](@ref).
772
772
773
- ```
773
+ ```julia-repl
774
774
julia> tanh(0.5f0)
775
775
0.46211717f0
776
776
@@ -808,11 +808,11 @@ tanh_fast(x::Number) = Base.tanh(x)
808
808
sigmoid_fast(x)
809
809
810
810
This is a faster, and very slightly less accurate, version of `sigmoid`.
811
- For `x::Float32, perhaps 3 times faster, and maximum errors 2 eps instead of 1.
811
+ For `x::Float32` , perhaps 3 times faster, and maximum errors 2 eps instead of 1.
812
812
813
813
See also [`tanh_fast`](@ref).
814
814
815
- ```
815
+ ```julia-repl
816
816
julia> sigmoid(0.2f0)
817
817
0.54983395f0
818
818
0 commit comments