weighted_minimal
ReservoirComputing.weighted_minimal — Functionweighted_minimal([rng], [T], dims...;
weight=0.1, return_sparse=false,
sampling_type=:no_sample)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.sampling_type: Sampling that decides the distribution ofweightnegative numbers. If set to:no_samplethe sign is unchanged. If set to:bernoulli_sample!then eachweightcan be positive with a probability set bypositive_prob. If set to:irrational_sample!theweightis negative if the decimal number of the irrational number chosen is odd. If set to:regular_sample!, each weight will be assigned a negative sign after the chosenstrides.stridescan be a single number or an array. Default is:no_sample.positive_prob: probability of theweightbeing positive whensampling_typeis set to:bernoulli_sample!. Default is 0.5.irrational: Irrational number whose decimals decide the sign ofweight. Default ispi.start: Which place after the decimal point the counting starts for theirrationalsign counting. Default is 1.strides: number of strides for assigning negative value to a weight. It can be an integer or an array. Default is 2.
Examples
julia> res_input = weighted_minimal(8, 3)
┌ Warning: Reservoir size has changed!
│
│ Computed reservoir size (6) does not equal the provided reservoir size (8).
│
│ Using computed value (6). Make sure to modify the reservoir initializer accordingly.
│
└ @ ReservoirComputing ~/.julia/dev/ReservoirComputing/src/esn/esn_inits.jl:159
6×3 Matrix{Float32}:
0.1 0.0 0.0
0.1 0.0 0.0
0.0 0.1 0.0
0.0 0.1 0.0
0.0 0.0 0.1
0.0 0.0 0.1
julia> res_input = weighted_minimal(9, 3; weight = 0.99)
9×3 Matrix{Float32}:
0.99 0.0 0.0
0.99 0.0 0.0
0.99 0.0 0.0
0.0 0.99 0.0
0.0 0.99 0.0
0.0 0.99 0.0
0.0 0.0 0.99
0.0 0.0 0.99
0.0 0.0 0.99
julia> res_input = weighted_minimal(9, 3; sampling_type = :bernoulli_sample!)
9×3 Matrix{Float32}:
0.1 -0.0 -0.0
-0.1 -0.0 -0.0
0.1 -0.0 0.0
-0.0 0.1 0.0
0.0 0.1 -0.0
0.0 0.1 0.0
-0.0 -0.0 -0.1
-0.0 -0.0 0.1
0.0 -0.0 0.1References
- 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.