weighted_minimal

ReservoirComputing.weighted_minimalFunction
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 is Utils.default_rng() from WeightInitializers.
  • T: Type of the elements in the reservoir matrix. Default is Float32.
  • dims: Dimensions of the matrix. Should follow res_size x in_size.

Keyword arguments

  • weight: The value for all the weights in the input matrix. Defaults to 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • signs: Controls sign flips. Use RandomSigns, RegularSigns, or IrrationalDigitSigns. Pass nothing to leave signs unchanged. Default is nothing.

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)
true

Random 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)
true

Example 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))
true
source

References