truedoublecycle
ReservoirComputing.true_doublecycle — Function
true_doublecycle([rng], [T], dims...;
cycle_weight=0.1, second_cycle_weight=0.1, radius=nothing,
return_sparse=false, cycle_kwargs=(), second_cycle_kwargs=())Creates a true double cycle reservoir, ispired by (Fu et al., 2023), with cycles built on the definition by (Rodan and Tino, 2011).
\[W_{i,j} = \begin{cases} r_1, & \text{if } i = j + 1,\;\; j \in [1, D_{\mathrm{res}} - 1], \\[4pt] r_1, & \text{if } i = 1,\;\; j = D_{\mathrm{res}}, \\[6pt] r_2, & \text{if } j = i + 1,\;\; i \in [1, D_{\mathrm{res}} - 1], \\[4pt] r_2, & \text{if } i = D_{\mathrm{res}},\;\; j = 1, \\[6pt] 0, & \text{otherwise.} \end{cases}\]
Arguments
rng: Random number generator. Default isUtils.default_rng()from WeightInitializers.T: Type of the elements in the reservoir matrix. Default isFloat32.dims: Dimensions of the reservoir matrix.
Keyword arguments
cycle_weight: Weight of the upper cycle connections in the reservoir matrix. Default is 0.1.second_cycle_weight: Weight of the lower cycle connections in the reservoir matrix. Default is 0.1.radius: The desired spectral radius of the reservoir. Ifnothingis passed, no scaling takes place. Defaults tonothing.return_sparse: flag for returning asparsematrix.truerequiresSparseArraysto be loaded. Default isfalse.cycle_kwargs, andsecond_cycle_kwargs: named tuples that control the kwargs for the weights generation. The kwargs are as follows:signs: Controls sign flips. UseRandomSigns,RegularSigns, orIrrationalDigitSigns. Passnothingto leave signs unchanged. Default isnothing.
Examples
Default call:
julia> res_matrix = true_doublecycle(5, 5)
5×5 Matrix{Float32}:
0.0 0.1 0.0 0.0 0.1
0.1 0.0 0.1 0.0 0.0
0.0 0.1 0.0 0.1 0.0
0.0 0.0 0.1 0.0 0.1
0.1 0.0 0.0 0.1 0.0Changing weights:
julia> res_matrix = true_doublecycle(5, 5; cycle_weight = 0.1, second_cycle_weight = 0.3)
5×5 Matrix{Float32}:
0.0 0.3 0.0 0.0 0.1
0.1 0.0 0.3 0.0 0.0
0.0 0.1 0.0 0.3 0.0
0.0 0.0 0.1 0.0 0.3
0.3 0.0 0.0 0.1 0.0Changing weights to custom arrays:
julia> cycle_weights = Float32[0.2, 0.4, 0.6, 0.8, 1.0];
julia> second_cycle_weights = -Float32[0.1, 0.3, 0.5, 0.7, 0.9];
julia> res_matrix = true_doublecycle(5, 5; cycle_weight = cycle_weights, second_cycle_weight = second_cycle_weights);
julia> size(res_matrix) == (5, 5) && eltype(res_matrix) == Float32 && count(!iszero, res_matrix) == 10
trueChanging sign of the weights with different sign patterns:
julia> res_matrix = true_doublecycle(5, 5; cycle_kwargs=(;signs = IrrationalDigitSigns()))
5×5 Matrix{Float32}:
0.0 0.1 0.0 0.0 -0.1
-0.1 0.0 0.1 0.0 0.0
0.0 0.1 0.0 0.1 0.0
0.0 0.0 -0.1 0.0 0.1
0.1 0.0 0.0 -0.1 0.0
julia> res_matrix = true_doublecycle(5, 5; second_cycle_kwargs=(;signs = RandomSigns()))
5×5 Matrix{Float32}:
0.0 -0.1 0.0 0.0 0.1
0.1 0.0 0.1 0.0 0.0
0.0 0.1 0.0 -0.1 0.0
0.0 0.0 0.1 0.0 0.1
0.1 0.0 0.0 0.1 0.0Returning as sparse:
julia> res_matrix = true_doublecycle(5, 5; return_sparse=true)
5×5 SparseMatrixCSC{Float32, Int64} with 10 stored entries:
⋅ 0.1 ⋅ ⋅ 0.1
0.1 ⋅ 0.1 ⋅ ⋅
⋅ 0.1 ⋅ 0.1 ⋅
⋅ ⋅ 0.1 ⋅ 0.1
0.1 ⋅ ⋅ 0.1 ⋅References
- Fu, J.; Li, G.; Tang, J.; Xia, L.; Wang, L. and Duan, S. (2023). A double-cycle echo state network topology for time series prediction. Chaos: An Interdisciplinary Journal of Nonlinear Science 33.
- Rodan, A. and Tino, P. (2011). Minimum Complexity Echo State Network. IEEE Transactions on Neural Networks 22, 131–144.