weighted_minimal
ReservoirComputing.weighted_minimal — Function
weighted_minimal([rng], [T], dims...;
weight=0.1, return_sparse=false,
signs = nothing)Create and return a minimal weighted input layer matrix. This initializer generates a weighted input matrix with equal, deterministic elements in the same construction as [weighted_minimal](@ref), inspired by (Lu et al., 2017).
Please note that this initializer computes its own reservoir size! If the computed reservoir size is different than the provided one it will raise a warning.
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 matrix. Should followres_size x in_size.
Keyword arguments
weight: The value for all the weights in the input matrix. Defaults to0.1.return_sparse: flag for returning asparsematrix. Default isfalse.signs: Controls sign flips. UseRandomSigns,RegularSigns, orIrrationalDigitSigns. Passnothingto leave signs unchanged. Default isnothing.
Examples
Standard call, changing the init weight:
julia> using Random, Test
julia> using ReservoirComputing: RandomSigns, weighted_minimal
julia> res_input = weighted_minimal(MersenneTwister(11), Float32, 9, 3; weight = 0.99);
julia> size(res_input) == (9, 3) && all(count(!iszero, column) == 3 for column in eachcol(res_input)) && all(iszero(weight) || weight == 0.99f0 for weight in res_input)
trueRandom sign flips for each weight:
julia> res_input = weighted_minimal(
MersenneTwister(12), Float32, 9, 3; signs = RandomSigns());
julia> all(count(!iszero, column) == 3 for column in eachcol(res_input)) &&
all(weight -> iszero(weight) || abs(weight) == 0.1f0, res_input)
trueExample of different reservoir size for the initializer:
julia> res_input = @test_logs (:warn, r"Reservoir size has changed") weighted_minimal(MersenneTwister(13), Float32, 8, 3);
julia> size(res_input) == (6, 3) && all(count(!iszero, column) == 2 for column in eachcol(res_input))
trueReferences
- Lu, Z.; Pathak, J.; Hunt, B.; Girvan, M.; Brockett, R. and Ott, E. (2017). Reservoir observers: Model-free inference of unmeasured variables in chaotic systems. Chaos: An Interdisciplinary Journal of Nonlinear Science 27.