Skip to content

Commit 82c633f

Browse files
uniformed naming, added equations
1 parent a1a8e4f commit 82c633f

File tree

4 files changed

+71
-13
lines changed

4 files changed

+71
-13
lines changed

docs/src/api/inits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
chaotic_init
2525
low_connectivity
2626
double_cycle
27-
self_loop_cycle
27+
selfloop_cycle
2828
selfloop_feedback_cycle
2929
selfloop_delayline_backward
3030
selfloop_forward_connection

src/ReservoirComputing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export scaled_rand, weighted_init, informed_init, minimal_init, chebyshev_mappin
4040
logistic_mapping, modified_lm
4141
export rand_sparse, delay_line, delay_line_backward, cycle_jumps,
4242
simple_cycle, pseudo_svd, chaotic_init, low_connectivity, double_cycle,
43-
self_loop_cycle, selfloop_feedback_cycle, selfloop_delayline_backward,
43+
selfloop_cycle, selfloop_feedback_cycle, selfloop_delayline_backward,
4444
selfloop_forward_connection, forward_connection
4545
export RNN, MRNN, GRU, GRUParams, FullyGated, Minimal
4646
export train

src/esn/esn_inits.jl

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,15 +1281,27 @@ function double_cycle(rng::AbstractRNG, ::Type{T}, dims::Integer...;
12811281
return return_init_as(Val(return_sparse), reservoir_matrix)
12821282
end
12831283

1284-
"""
1285-
self_loop_cycle([rng], [T], dims...;
1284+
@doc raw"""
1285+
selfloop_cycle([rng], [T], dims...;
12861286
cycle_weight=0.1, selfloop_weight=0.1,
12871287
return_sparse=false)
12881288
12891289
Creates a simple cycle reservoir with the addition of self loops [^elsarraj2019].
12901290
12911291
This architecture is referred to as TP1 in the original paper.
12921292
1293+
# Equations
1294+
1295+
```math
1296+
W_{i,j} =
1297+
\begin{cases}
1298+
ll, & \text{if } i = j \\
1299+
r, & \text{if } j = i - 1 \text{ for } i = 2 \dots N \\
1300+
r, & \text{if } i = 1, j = N \\
1301+
0, & \text{otherwise}
1302+
\end{cases}
1303+
```
1304+
12931305
# Arguments
12941306
12951307
- `rng`: Random number generator. Default is `Utils.default_rng()`
@@ -1309,15 +1321,15 @@ This architecture is referred to as TP1 in the original paper.
13091321
# Examples
13101322
13111323
```jldoctest
1312-
julia> reservoir_matrix = self_loop_cycle(5, 5)
1324+
julia> reservoir_matrix = selfloop_cycle(5, 5)
13131325
5×5 Matrix{Float32}:
13141326
0.1 0.0 0.0 0.0 0.1
13151327
0.1 0.1 0.0 0.0 0.0
13161328
0.0 0.1 0.1 0.0 0.0
13171329
0.0 0.0 0.1 0.1 0.0
13181330
0.0 0.0 0.0 0.1 0.1
13191331
1320-
julia> reservoir_matrix = self_loop_cycle(5, 5; weight=0.2, selfloop_weight=0.5)
1332+
julia> reservoir_matrix = selfloop_cycle(5, 5; weight=0.2, selfloop_weight=0.5)
13211333
5×5 Matrix{Float32}:
13221334
0.5 0.0 0.0 0.0 0.2
13231335
0.2 0.5 0.0 0.0 0.0
@@ -1330,7 +1342,7 @@ julia> reservoir_matrix = self_loop_cycle(5, 5; weight=0.2, selfloop_weight=0.5)
13301342
"Demystifying echo state network with deterministic simple topologies."
13311343
International Journal of Computational Science and Engineering 19.3 (2019): 407-417.
13321344
"""
1333-
function self_loop_cycle(rng::AbstractRNG, ::Type{T}, dims::Integer...;
1345+
function selfloop_cycle(rng::AbstractRNG, ::Type{T}, dims::Integer...;
13341346
cycle_weight=T(0.1f0), selfloop_weight=T(0.1f0),
13351347
return_sparse::Bool=false) where {T <: Number}
13361348
throw_sparse_error(return_sparse)
@@ -1340,7 +1352,7 @@ function self_loop_cycle(rng::AbstractRNG, ::Type{T}, dims::Integer...;
13401352
return return_init_as(Val(return_sparse), reservoir_matrix)
13411353
end
13421354

1343-
"""
1355+
@doc raw"""
13441356
selfloop_feedback_cycle([rng], [T], dims...;
13451357
cycle_weight=0.1, selfloop_weight=0.1,
13461358
return_sparse=false)
@@ -1350,6 +1362,19 @@ self loops on odd neurons [^elsarraj2019].
13501362
13511363
This architecture is referred to as TP2 in the original paper.
13521364
1365+
# Equations
1366+
1367+
```math
1368+
W_{i,j} =
1369+
\begin{cases}
1370+
r, & \text{if } j = i - 1 \text{ for } i = 2 \dots N \\
1371+
r, & \text{if } i = 1, j = N \\
1372+
ll, & \text{if } i = j \text{ and } i \text{ is odd} \\
1373+
r, & \text{if } j = i + 1 \text{ and } i \text{ is even}, i \neq N \\
1374+
0, & \text{otherwise}
1375+
\end{cases}
1376+
```
1377+
13531378
# Arguments
13541379
13551380
- `rng`: Random number generator. Default is `Utils.default_rng()`
@@ -1409,7 +1434,7 @@ function selfloop_feedback_cycle(rng::AbstractRNG, ::Type{T}, dims::Integer...;
14091434
return return_init_as(Val(return_sparse), reservoir_matrix)
14101435
end
14111436

1412-
"""
1437+
@doc raw"""
14131438
selfloop_delayline_backward([rng], [T], dims...;
14141439
weight=0.1, selfloop_weight=0.1,
14151440
return_sparse=false)
@@ -1419,6 +1444,18 @@ backward connections shifted by one [^elsarraj2019].
14191444
14201445
This architecture is referred to as TP3 in the original paper.
14211446
1447+
# Equations
1448+
1449+
```math
1450+
W_{i,j} =
1451+
\begin{cases}
1452+
ll, & \text{if } i = j \text{ for } i = 1 \dots N \\
1453+
r, & \text{if } j = i - 1 \text{ for } i = 2 \dots N \\
1454+
r, & \text{if } j = i - 2 \text{ for } i = 3 \dots N \\
1455+
0, & \text{otherwise}
1456+
\end{cases}
1457+
```
1458+
14221459
# Arguments
14231460
14241461
- `rng`: Random number generator. Default is `Utils.default_rng()`
@@ -1474,7 +1511,7 @@ function selfloop_delayline_backward(rng::AbstractRNG, ::Type{T}, dims::Integer.
14741511
return return_init_as(Val(return_sparse), reservoir_matrix)
14751512
end
14761513

1477-
"""
1514+
@doc raw"""
14781515
selfloop_forward_connection([rng], [T], dims...;
14791516
weight=0.1, selfloop_weight=0.1,
14801517
return_sparse=false)
@@ -1484,6 +1521,17 @@ with the addition of self loops [^elsarraj2019].
14841521
14851522
This architecture is referred to as TP4 in the original paper.
14861523
1524+
# Equations
1525+
1526+
```math
1527+
W_{i,j} =
1528+
\begin{cases}
1529+
ll, & \text{if } i = j \text{ for } i = 1 \dots N \\
1530+
r, & \text{if } j = i - 2 \text{ for } i = 3 \dots N \\
1531+
0, & \text{otherwise}
1532+
\end{cases}
1533+
```
1534+
14871535
# Arguments
14881536
14891537
- `rng`: Random number generator. Default is `Utils.default_rng()`
@@ -1536,7 +1584,7 @@ function selfloop_forward_connection(rng::AbstractRNG, ::Type{T}, dims::Integer.
15361584
return return_init_as(Val(return_sparse), reservoir_matrix)
15371585
end
15381586

1539-
"""
1587+
@doc raw"""
15401588
forward_connection([rng], [T], dims...;
15411589
weight=0.1, selfloop_weight=0.1,
15421590
return_sparse=false)
@@ -1545,6 +1593,16 @@ Creates a reservoir based on a forward connection of weights [^elsarraj2019].
15451593
15461594
This architecture is referred to as TP5 in the original paper.
15471595
1596+
# Equations
1597+
1598+
```math
1599+
W_{i,j} =
1600+
\begin{cases}
1601+
r, & \text{if } j = i - 2 \text{ for } i = 3 \dots N \\
1602+
0, & \text{otherwise}
1603+
\end{cases}
1604+
```
1605+
15481606
# Arguments
15491607
15501608
- `rng`: Random number generator. Default is `Utils.default_rng()`
@@ -1598,7 +1656,7 @@ end
15981656
for initializer in (:rand_sparse, :delay_line, :delay_line_backward, :cycle_jumps,
15991657
:simple_cycle, :pseudo_svd, :chaotic_init,
16001658
:scaled_rand, :weighted_init, :informed_init, :minimal_init, :chebyshev_mapping,
1601-
:logistic_mapping, :modified_lm, :low_connectivity, :double_cycle, :self_loop_cycle,
1659+
:logistic_mapping, :modified_lm, :low_connectivity, :double_cycle, :selfloop_cycle,
16021660
:selfloop_feedback_cycle, :selfloop_delayline_backward, :selfloop_forward_connection,
16031661
:forward_connection)
16041662
@eval begin

test/esn/test_inits.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ reservoir_inits = [
2828
chaotic_init,
2929
low_connectivity,
3030
double_cycle,
31-
self_loop_cycle,
31+
selfloop_cycle,
3232
selfloop_feedback_cycle,
3333
selfloop_delayline_backward,
3434
selfloop_forward_connection,

0 commit comments

Comments
 (0)