delaylinebackward

ReservoirComputing.delayline_backwardFunction
delayline_backward([rng], [T], dims...;
    delay_weight=0.1, fb_weight=0.1,
    delay_shift=1, fb_shift=1, return_sparse=false,
    radius=nothing, delay_kwargs=(), fb_kwargs=())

Create a delay line backward reservoir with the specified by dims and weights. Creates a matrix with backward connections as described in (Rodan and Tino, 2011).

\[W_{i,j} = \begin{cases} r, & \text{if } i = j + 1,\;\; j \in [1, D_{\mathrm{res}} - 1], \\[4pt] b, & \text{if } j = i + 1,\;\; i \in [1, D_{\mathrm{res}} - 1], \\[6pt] 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

  • delay_weight: The weight determines the absolute value of forward connections in the reservoir. 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.

  • fb_weight: Determines the absolute value of backward connections in the reservoir. 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.

  • fb_shift: How far the backward connection will be from the diagonal. Default is 1.

  • delay_shift: delay line shift relative to the diagonal. Default is 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.

  • delay_kwargs and fb_kwargs: named tuples that control the kwargs for the delay line weight and feedback weights respectively. The kwargs are as follows:

Examples

Default call:

julia> res_matrix = delayline_backward(5, 5)
5×5 Matrix{Float32}:
 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.0
 0.0  0.0  0.1  0.0  0.1
 0.0  0.0  0.0  0.1  0.0

Changing weights:

julia> res_matrix = delayline_backward(5, 5; delay_weight = 0.99, fb_weight=-1.0)
5×5 Matrix{Float32}:
 0.0   -1.0    0.0    0.0    0.0
 0.99   0.0   -1.0    0.0    0.0
 0.0    0.99   0.0   -1.0    0.0
 0.0    0.0    0.99   0.0   -1.0
 0.0    0.0    0.0    0.99   0.0

Changing weights to custom arrays:

julia> delay_weights = Float32[0.2, 0.4, 0.6, 0.8];

julia> feedback_weights = -Float32[0.1, 0.3, 0.5, 0.7];

julia> res_matrix = delayline_backward(5, 5;
           delay_weight = delay_weights, fb_weight = feedback_weights);

julia> res_matrix[2, 1] == 0.2f0 && res_matrix[1, 2] == -0.1f0 &&
       res_matrix[5, 4] == 0.8f0 && res_matrix[4, 5] == -0.7f0
true

Changing sign of the weights with different sign patterns:

julia> res_matrix = delayline_backward(5, 5; delay_kwargs=(;signs = IrrationalDigitSigns()))
5×5 Matrix{Float32}:
  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.0
  0.0  0.0  -0.1   0.0  0.1
  0.0  0.0   0.0  -0.1  0.0

julia> res_matrix = delayline_backward(5, 5; fb_kwargs=(;signs = RandomSigns()))
5×5 Matrix{Float32}:
 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.0
 0.0  0.0   0.1  0.0  -0.1
 0.0  0.0   0.0  0.1   0.0

Shifting:

julia> res_matrix = delayline_backward(5, 5; delay_shift=3, fb_shift=2)
5×5 Matrix{Float32}:
 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.1  0.0  0.0  0.0  0.0
 0.0  0.1  0.0  0.0  0.0

Returning as sparse:

julia> using SparseArrays

julia> res_matrix = delayline_backward(5, 5; return_sparse=true)
5×5 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