@@ -1283,11 +1283,13 @@ end
12831283
12841284"""
12851285 self_loop_cycle([rng], [T], dims...;
1286- cycle_weight=0.1, self_loop_weight =0.1,
1286+ cycle_weight=0.1, selfloop_weight =0.1,
12871287 return_sparse=false)
12881288
12891289Creates a simple cycle reservoir with the addition of self loops [^elsarraj2019].
12901290
1291+ This architecture is referred to as TP1 in the original paper.
1292+
12911293# Arguments
12921294
12931295 - `rng`: Random number generator. Default is `Utils.default_rng()`
@@ -1297,9 +1299,9 @@ Creates a simple cycle reservoir with the addition of self loops [^elsarraj2019]
12971299
12981300# Keyword arguments
12991301
1300- - `cycle_weight`: Weight of the upper cycle connections in the reservoir matrix.
1302+ - `cycle_weight`: Weight of the cycle connections in the reservoir matrix.
13011303 Default is 0.1.
1302- - `self_loop_weight `: Weight of the self loops in the reservoir matrix.
1304+ - `selfloop_weight `: Weight of the self loops in the reservoir matrix.
13031305 Default is 0.1.
13041306 - `return_sparse`: flag for returning a `sparse` matrix.
13051307 Default is `false`.
@@ -1315,7 +1317,7 @@ julia> reservoir_matrix = self_loop_cycle(5, 5)
13151317 0.0 0.0 0.1 0.1 0.0
13161318 0.0 0.0 0.0 0.1 0.1
13171319
1318- julia> reservoir_matrix = self_loop_cycle(5, 5; weight=0.2, self_loop_weight =0.5)
1320+ julia> reservoir_matrix = self_loop_cycle(5, 5; weight=0.2, selfloop_weight =0.5)
131913215×5 Matrix{Float32}:
13201322 0.5 0.0 0.0 0.0 0.2
13211323 0.2 0.5 0.0 0.0 0.0
@@ -1329,12 +1331,81 @@ julia> reservoir_matrix = self_loop_cycle(5, 5; weight=0.2, self_loop_weight=0.5
13291331 International Journal of Computational Science and Engineering 19.3 (2019): 407-417.
13301332"""
13311333function self_loop_cycle (rng:: AbstractRNG , :: Type{T} , dims:: Integer... ;
1332- weight = T (0.1f0 ), self_loop_weight = T (0.1f0 ),
1334+ cycle_weight = T (0.1f0 ), selfloop_weight = T (0.1f0 ),
13331335 return_sparse:: Bool = false ) where {T <: Number }
13341336 throw_sparse_error (return_sparse)
13351337 reservoir_matrix = simple_cycle (rng, T, dims... ;
1336- weight= weight, return_sparse= false )
1337- reservoir_matrix += T (self_loop_weight) .* I (dims[1 ])
1338+ weight= cycle_weight, return_sparse= false )
1339+ reservoir_matrix += T (selfloop_weight) .* I (dims[1 ])
1340+ return return_init_as (Val (return_sparse), reservoir_matrix)
1341+ end
1342+
1343+ """
1344+ selfloop_feedback_cycle([rng], [T], dims...;
1345+ cycle_weight=0.1, selfloop_weight=0.1,
1346+ return_sparse=false)
1347+
1348+ Creates a cycle reservoir with feedback connections on even neurons and
1349+ self loops on odd neurons [^elsarraj2019].
1350+
1351+ This architecture is referred to as TP2 in the original paper.
1352+
1353+ # Arguments
1354+
1355+ - `rng`: Random number generator. Default is `Utils.default_rng()`
1356+ from WeightInitializers.
1357+ - `T`: Type of the elements in the reservoir matrix. Default is `Float32`.
1358+ - `dims`: Dimensions of the reservoir matrix.
1359+
1360+ # Keyword arguments
1361+
1362+ - `cycle_weight`: Weight of the cycle connections in the reservoir matrix.
1363+ Default is 0.1.
1364+ - `selfloop_weight`: Weight of the self loops in the reservoir matrix.
1365+ Default is 0.1.
1366+ - `return_sparse`: flag for returning a `sparse` matrix.
1367+ Default is `false`.
1368+
1369+ # Examples
1370+
1371+ ```jldoctest
1372+ julia> reservoir_matrix = selfloop_feedback_cycle(5, 5)
1373+ 5×5 Matrix{Float32}:
1374+ 0.1 0.1 0.0 0.0 0.1
1375+ 0.1 0.0 0.0 0.0 0.0
1376+ 0.0 0.1 0.1 0.1 0.0
1377+ 0.0 0.0 0.1 0.0 0.0
1378+ 0.0 0.0 0.0 0.1 0.1
1379+
1380+ julia> reservoir_matrix = selfloop_feedback_cycle(5, 5; self_loop_weight=0.5)
1381+ 5×5 Matrix{Float32}:
1382+ 0.5 0.1 0.0 0.0 0.1
1383+ 0.1 0.0 0.0 0.0 0.0
1384+ 0.0 0.1 0.5 0.1 0.0
1385+ 0.0 0.0 0.1 0.0 0.0
1386+ 0.0 0.0 0.0 0.1 0.5
1387+ ```
1388+
1389+ [^elsarraj2019]: Elsarraj, Duaa, et al.
1390+ "Demystifying echo state network with deterministic simple topologies."
1391+ International Journal of Computational Science and Engineering 19.3 (2019): 407-417.
1392+ """
1393+ function selfloop_feedback_cycle (rng:: AbstractRNG , :: Type{T} , dims:: Integer... ;
1394+ cycle_weight= T (0.1f0 ), selfloop_weight= T (0.1f0 ),
1395+ return_sparse:: Bool = false ) where {T <: Number }
1396+ throw_sparse_error (return_sparse)
1397+ reservoir_matrix = simple_cycle (rng, T, dims... ;
1398+ weight= T (cycle_weight), return_sparse= false )
1399+ for idx in axes (reservoir_matrix, 1 )
1400+ if isodd (idx)
1401+ reservoir_matrix[idx, idx] = T (selfloop_weight)
1402+ end
1403+ end
1404+ for idx in (first (axes (reservoir_matrix, 1 )) + 1 ): last (axes (reservoir_matrix, 1 ))
1405+ if iseven (idx)
1406+ reservoir_matrix[idx - 1 , idx] = T (cycle_weight)
1407+ end
1408+ end
13381409 return return_init_as (Val (return_sparse), reservoir_matrix)
13391410end
13401411
@@ -1343,7 +1414,8 @@ end
13431414for initializer in (:rand_sparse , :delay_line , :delay_line_backward , :cycle_jumps ,
13441415 :simple_cycle , :pseudo_svd , :chaotic_init ,
13451416 :scaled_rand , :weighted_init , :informed_init , :minimal_init , :chebyshev_mapping ,
1346- :logistic_mapping , :modified_lm , :low_connectivity , :double_cycle , :self_loop_cycle )
1417+ :logistic_mapping , :modified_lm , :low_connectivity , :double_cycle , :self_loop_cycle ,
1418+ :selfloop_feedback_cycle )
13471419 @eval begin
13481420 function ($ initializer)(dims:: Integer... ; kwargs... )
13491421 return $ initializer (Utils. default_rng (), Float32, dims... ; kwargs... )
0 commit comments