self_loop!
ReservoirComputing.self_loop! — Function
self_loop!([rng], reservoir_matrix, weight; signs = nothing)Sets the diagonal of reservoir_matrix to weight, adding a self loop to each node. weight can be a number, a vector of length size(reservoir_matrix, 1), or a function weight(rng, n) returning such a vector.
Arguments
rng: Random number generator. Default isXoshiro(1234).reservoir_matrix: matrix to be changed.weight: weight to add as a self loop. Can be either a single number or an array.
Keyword arguments
signs: Controls sign flips. UseRandomSigns,RegularSigns, orIrrationalDigitSigns. Passnothingto leave signs unchanged. Default isnothing.
Examples
julia> matrix = zeros(Float32, 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.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
julia> self_loop!(matrix, 1.0);
julia> diag(matrix) == fill(1.0f0, 5)
true