delay_line
ReservoirComputing.delay_line — Function
delay_line([rng], [T], dims...;
delay_weight=0.1, delay_shift=1,
return_sparse=false, radius=nothing, kwargs...)Create and return a delay line reservoir matrix (Rodan and Tino, 2011).
\[W_{i,j} = \begin{cases} r, & \text{if } i = j + 1, j \in [1, D_{\mathrm{res}} - 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
delay_weight: Determines the value of all 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.delay_shift: delay line shift. Default is 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.signs: Controls sign flips. UseRandomSigns,RegularSigns, orIrrationalDigitSigns. Passnothingto leave signs unchanged. Default isnothing.
Examples
Default call:
julia> res_matrix = delay_line(5, 5)
5×5 Matrix{Float32}:
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
0.0 0.0 0.0 0.1 0.0Changing weights:
julia> res_matrix = delay_line(5, 5; delay_weight = 1)
5×5 Matrix{Float32}:
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.0
0.0 0.0 0.0 1.0 0.0Changing weights to a custom array:
julia> delay_weights = Float32[0.2, 0.4, 0.6, 0.8];
julia> res_matrix = delay_line(5, 5; delay_weight = delay_weights);
julia> res_matrix[2:end, 1:end-1] == Diagonal(delay_weights)
trueChanging sign of the weights with different sign patterns:
julia> irrational_matrix = delay_line(5, 5; signs = IrrationalDigitSigns());
julia> bernoulli_matrix = delay_line(MersenneTwister(123), 5, 5; signs = RandomSigns());
julia> all(abs.(irrational_matrix[irrational_matrix .!= 0]) .== 0.1f0) &&
all(abs.(bernoulli_matrix[bernoulli_matrix .!= 0]) .== 0.1f0)
trueShifting the delay line:
julia> res_matrix = delay_line(5, 5; delay_shift = 3)
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.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.0Returning as sparse:
julia> using SparseArrays
julia> res_matrix = delay_line(5, 5; return_sparse=true)
5×5 SparseMatrixCSC{Float32, Int64} with 4 stored entries:
⋅ ⋅ ⋅ ⋅ ⋅
0.1 ⋅ ⋅ ⋅ ⋅
⋅ 0.1 ⋅ ⋅ ⋅
⋅ ⋅ 0.1 ⋅ ⋅
⋅ ⋅ ⋅ 0.1 ⋅References
- Rodan, A. and Tino, P. (2011). Minimum Complexity Echo State Network. IEEE Transactions on Neural Networks 22, 131–144.