forward_connection

ReservoirComputing.forward_connectionFunction
forward_connection([rng], [T], dims...;
    forward_weight=0.1, radius=nothing, return_sparse=false,
    kwargs...)

Creates a reservoir based on a forward connection of weights (Elsarraj et al., 2019).

This architecture is referred to as TP5 in the original paper.

\[W_{i,j} = \begin{cases} r, & \text{if } j = i - 2 \text{ for } i = 3 \dots N \\ 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

  • forward_weight: Weight of the cycle connections in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the length of the array matches the length of the sub-diagonal you want to populate. 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.
  • signs: Controls sign flips. Use RandomSigns, RegularSigns, or IrrationalDigitSigns. Pass nothing to leave signs unchanged. Default is nothing.

Examples

Default kwargs:

julia> reservoir_matrix = forward_connection(5, 5)
5×5 Matrix{Float32}:
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.1  0.0  0.0  0.0  0.0
 0.0  0.1  0.0  0.0  0.0
 0.0  0.0  0.1  0.0  0.0

Changing the weights magnitudes to a different unique value:

julia> forward_connection(5, 5; forward_weight=0.99)
5×5 Matrix{Float32}:
 0.0   0.0   0.0   0.0  0.0
 0.0   0.0   0.0   0.0  0.0
 0.99  0.0   0.0   0.0  0.0
 0.0   0.99  0.0   0.0  0.0
 0.0   0.0   0.99  0.0  0.0

Changing the weights signs with different sign patterns:

julia> reservoir_matrix = forward_connection(5, 5; signs = IrrationalDigitSigns());

julia> size(reservoir_matrix), count(x -> !iszero(x), reservoir_matrix),
       all(abs.(reservoir_matrix[reservoir_matrix .!= 0]) .== 0.1f0)
((5, 5), 3, true)

Changing the weights to random numbers. Note that the length of the given array must be at least as long as the subdiagonal one wants to fill:

julia> reservoir_matrix = forward_connection(5, 5;
           forward_weight=Float32[0.2, 0.4, 0.6]);

julia> reservoir_matrix[3, 1] == 0.2f0 && reservoir_matrix[4, 2] == 0.4f0 &&
       reservoir_matrix[5, 3] == 0.6f0
true

Returning a sparse matrix:

julia> reservoir_matrix = forward_connection(10, 10; return_sparse=true)
10×10 SparseMatrixCSC{Float32, Int64} with 8 stored entries:
  ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅
 0.1   ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅   0.1   ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅   0.1   ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅   0.1   ⋅    ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅   0.1   ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅    ⋅   0.1   ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅    ⋅    ⋅   0.1   ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅    ⋅    ⋅    ⋅   0.1   ⋅    ⋅
source

References

  • Elsarraj, D.; Qisi, M. A.; Rodan, A.; Obeid, N.; Sharieh, A. and Faris, H. (2019). Demystifying echo state network with deterministic simple topologies. International Journal of Computational Science and Engineering 19, 407–417.