double_cycle

ReservoirComputing.double_cycleFunction
double_cycle([rng], [T], dims...;
    cycle_weight=0.1, second_cycle_weight=0.1,
    radius=nothing, return_sparse=false)

Creates a double cycle reservoir (Fu et al., 2023).

\[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 = D_{\mathrm{res}},\;\; j = 1, \\[6pt] r_2, & \text{if } i = 1,\;\; j = D_{\mathrm{res}}, \\[6pt] r_2, & \text{if } j = i + 1,\;\; i \in [1, D_{\mathrm{res}} - 1], \\[4pt] 0, & \text{otherwise.} \end{cases}\]

Arguments

  • rng: Random number generator. Default is Utils.default_rng()from WeightInitializers.
  • T: Type of the elements in the reservoir matrix. Default is Float32.
  • 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. If nothing is passed, no scaling takes place. Defaults to nothing.
  • return_sparse: flag for returning a sparse matrix. true requires SparseArrays to be loaded. Default is false.

Examples

Default call:

julia> res_matrix = double_cycle(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.0

Changing weights:

julia> res_matrix = double_cycle(5, 5; cycle_weight = -0.1, second_cycle_weight = 0.3)
5×5 Matrix{Float32}:
  0.0   0.3   0.0   0.0  0.3
 -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.1   0.0   0.0  -0.1  0.0
source

References