Echo State Networks Initializers

Input layers

ReservoirComputing.scaled_randFunction
scaled_rand([rng], [T], dims...;
    scaling=0.1)

Create and return a matrix with random values, uniformly distributed within a range defined by scaling.

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

  • scaling: A scaling factor to define the range of the uniform distribution. The matrix elements will be randomly chosen from the range [-scaling, scaling]. Defaults to 0.1.

Examples

julia> res_input = scaled_rand(8, 3)
8×3 Matrix{Float32}:
 -0.0669356  -0.0292692  -0.0188943
  0.0159724   0.004071   -0.0737949
  0.026355   -0.0191563   0.0714962
 -0.0177412   0.0279123   0.0892906
 -0.0184405   0.0567368   0.0190222
  0.0944272   0.0679244   0.0148647
 -0.0799005  -0.0891089  -0.0444782
 -0.0970182   0.0934286   0.03553
source
ReservoirComputing.weighted_initFunction
weighted_init([rng], [T], dims...;
    scaling=0.1, return_sparse=false)

Create and return a matrix representing a weighted input layer. This initializer generates a weighted input matrix with random non-zero elements distributed uniformly within the range [-scaling, scaling] (Lu et al., 2017).

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

  • scaling: The scaling factor for the weight distribution. Defaults to 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.

Examples

julia> res_input = weighted_init(8, 3)
6×3 Matrix{Float32}:
  0.0452399   0.0          0.0
 -0.0348047   0.0          0.0
  0.0        -0.0386004    0.0
  0.0         0.00981022   0.0
  0.0         0.0          0.0577838
  0.0         0.0         -0.0562827
source
ReservoirComputing.minimal_initFunction
minimal_init([rng], [T], dims...;
    sampling_type=:bernoulli_sample!, weight=0.1, irrational=pi,
    start=1, p=0.5)

Create a layer matrix with uniform weights determined by weight (Rodan and Tino, 2011). The sign difference is randomly determined by the sampling chosen.

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 weight used to fill the layer matrix. Default is 0.1.
  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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 = minimal_init(8, 3)
8×3 Matrix{Float32}:
  0.1  -0.1   0.1
 -0.1   0.1   0.1
 -0.1  -0.1   0.1
 -0.1  -0.1  -0.1
  0.1   0.1   0.1
 -0.1  -0.1  -0.1
 -0.1  -0.1   0.1
  0.1  -0.1   0.1

julia> res_input = minimal_init(8, 3; sampling_type = :irrational)
8×3 Matrix{Float32}:
 -0.1   0.1  -0.1
  0.1  -0.1  -0.1
  0.1   0.1  -0.1
  0.1   0.1   0.1
 -0.1  -0.1  -0.1
  0.1   0.1   0.1
  0.1   0.1  -0.1
 -0.1   0.1  -0.1

julia> res_input = minimal_init(8, 3; p = 0.1) # lower p -> more negative signs
8×3 Matrix{Float32}:
 -0.1  -0.1  -0.1
 -0.1  -0.1  -0.1
 -0.1  -0.1  -0.1
 -0.1  -0.1  -0.1
  0.1  -0.1  -0.1
 -0.1  -0.1  -0.1
 -0.1  -0.1  -0.1
 -0.1  -0.1  -0.1

julia> res_input = minimal_init(8, 3; p = 0.8)# higher p -> more positive signs
8×3 Matrix{Float32}:
  0.1   0.1  0.1
 -0.1   0.1  0.1
 -0.1   0.1  0.1
  0.1   0.1  0.1
  0.1   0.1  0.1
  0.1  -0.1  0.1
 -0.1   0.1  0.1
  0.1   0.1  0.1
source
ReservoirComputing.weighted_minimalFunction
weighted_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 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.
  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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.1
source
ReservoirComputing.chebyshev_mappingFunction
chebyshev_mapping([rng], [T], dims...;
    amplitude=one(T), sine_divisor=one(T),
    chebyshev_parameter=one(T), return_sparse=false)

Generate a Chebyshev-mapped matrix (Xie et al., 2024). The first row is initialized using a sine function and subsequent rows are iteratively generated via the Chebyshev mapping. The first row is defined as:

\[ W[1, j] = \text{amplitude} \cdot \sin(j \cdot \pi / (\text{sine_divisor} \cdot \text{n_cols}))\]

for j = 1, 2, …, ncols (with ncols typically equal to K+1, where K is the number of input layer neurons). Subsequent rows are generated by applying the mapping:

\[ W[i+1, j] = \cos( \text{chebyshev_parameter} \cdot \acos(W[pi, j]))\]

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. res_size is assumed to be K+1.

Keyword arguments

  • amplitude: Scaling factor used to initialize the first row. This parameter adjusts the amplitude of the sine function. Default value is one.
  • sine_divisor: Divisor applied in the sine function's phase. Default value is one.
  • chebyshev_parameter: Control parameter for the Chebyshev mapping in subsequent rows. This parameter influences the distribution of the matrix elements. Default is one.
  • return_sparse: If true, the function returns the matrix as a sparse matrix. Default is false.

Examples

julia> input_matrix = chebyshev_mapping(10, 3)
10×3 Matrix{Float32}:
 0.866025  0.866025   1.22465f-16
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
 0.866025  0.866025  -4.37114f-8
source
ReservoirComputing.logistic_mappingFunction
logistic_mapping([rng], [T], dims...;
    amplitude=0.3, sine_divisor=5.9, logistic_parameter=3.7,
    return_sparse=false)

Generate an input weight matrix using a logistic mapping (Wang et al., 2022) The first row is initialized using a sine function:

\[ W[1, j] = \text{amplitude} \cdot \sin(j \cdot \pi / (\text{sine_divisor} \cdot in_size))\]

for each input index j, with in_size being the number of columns provided in dims. Subsequent rows are generated recursively using the logistic map recurrence:

\[ W[i+1, j] = \text{logistic_parameter} \cdot W(i, j) \cdot (1 - W[i, j])\]

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

  • amplitude: Scaling parameter used in the sine initialization of the first row. Default is 0.3.
  • sine_divisor: Parameter used to adjust the phase in the sine initialization. Default is 5.9.
  • logistic_parameter: The parameter in the logistic mapping recurrence that governs the dynamics. Default is 3.7.
  • return_sparse: If true, returns the resulting matrix as a sparse matrix. Default is false.

Examples

julia> logistic_mapping(8, 3)
8×3 Matrix{Float32}:
 0.0529682  0.104272  0.1523
 0.185602   0.345578  0.477687
 0.559268   0.836769  0.923158
 0.912003   0.50537   0.262468
 0.296938   0.924893  0.716241
 0.772434   0.257023  0.751987
 0.650385   0.70656   0.69006
 0.841322   0.767132  0.791346
source
ReservoirComputing.modified_lmFunction
modified_lm([rng], [T], dims...;
    factor, amplitude=0.3, sine_divisor=5.9, logistic_parameter=2.35,
    return_sparse=false)

Generate a input weight matrix based on the logistic mapping (Viehweg et al., 2025). Thematrix is built so that each input is transformed into a high-dimensional feature space via a recursive logistic map. For each input, a chain of weights is generated as follows:

  • The first element of the chain is initialized using a sine function:

\[ W[1,j] = \text{amplitude} \cdot \sin( (j \cdot \pi) / (\text{factor} \cdot \text{n} \cdot \text{sine_divisor}) )\]

where j is the index corresponding to the input and n is the number of inputs.

  • Subsequent elements are recursively computed using the logistic mapping:

\[ W[i+1,j] = \text{logistic_parameter} \cdot W[i,j] \cdot (1 - W[i,j])\]

The resulting matrix has dimensions (factor * in_size) x in_size, where in_size corresponds to the number of columns provided in dims. If the provided number of rows does not match factor * in_size the number of rows is overridden.

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

  • factor: The number of logistic map iterations (chain length) per input, determining the number of rows per input.
  • amplitude: Scaling parameter A for the sine-based initialization of the first element in each logistic chain. Default is 0.3.
  • sine_divisor: Parameter B used to adjust the phase in the sine initialization. Default is 5.9.
  • logistic_parameter: The parameter r in the logistic recurrence that governs the chain dynamics. Default is 2.35.
  • return_sparse: If true, returns the resulting matrix as a sparse matrix. Default is false.

Examples

julia> modified_lm(20, 10; factor=2)
20×10 SparseArrays.SparseMatrixCSC{Float32, Int64} with 18 stored entries:
⎡⢠⠀⠀⠀⠀⎤
⎢⠀⢣⠀⠀⠀⎥
⎢⠀⠀⢣⠀⠀⎥
⎢⠀⠀⠀⢣⠀⎥
⎣⠀⠀⠀⠀⢣⎦

julia> modified_lm(12, 4; factor=3)
12×4 SparseArrays.SparseMatrixCSC{Float32, Int64} with 9 stored entries:
  ⋅    ⋅          ⋅          ⋅ 
  ⋅    ⋅          ⋅          ⋅ 
  ⋅    ⋅          ⋅          ⋅ 
  ⋅   0.0133075   ⋅          ⋅ 
  ⋅   0.0308564   ⋅          ⋅ 
  ⋅   0.070275    ⋅          ⋅ 
  ⋅    ⋅         0.0265887   ⋅ 
  ⋅    ⋅         0.0608222   ⋅ 
  ⋅    ⋅         0.134239    ⋅ 
  ⋅    ⋅          ⋅         0.0398177
  ⋅    ⋅          ⋅         0.0898457
  ⋅    ⋅          ⋅         0.192168
source
ReservoirComputing.informed_initFunction
informed_init([rng], [T], dims...;
    scaling=0.1, model_in_size, gamma=0.5)

Create an input layer for informed echo state networks (Pathak et al., 2018).

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

  • scaling: The scaling factor for the input matrix. Default is 0.1.
  • model_in_size: The size of the input model.
  • gamma: The gamma value. Default is 0.5.

Examples

source

Reservoirs

ReservoirComputing.rand_sparseFunction
rand_sparse([rng], [T], dims...;
    radius=1.0, sparsity=0.1, std=1.0, return_sparse=false)

Create and return a random sparse reservoir matrix. The matrix will be of size specified by dims, with specified sparsity and scaled spectral radius according to radius.

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 reservoir matrix.

Keyword arguments

  • radius: The desired spectral radius of the reservoir. Defaults to 1.0.
  • sparsity: The sparsity level of the reservoir matrix, controlling the fraction of zero elements. Defaults to 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.

Examples

julia> res_matrix = rand_sparse(5, 5; sparsity = 0.5)
5×5 Matrix{Float32}:
 0.0        0.0        0.0        0.0      0.0
 0.0        0.794565   0.0        0.26164  0.0
 0.0        0.0       -0.931294   0.0      0.553706
 0.723235  -0.524727   0.0        0.0      0.0
 1.23723    0.0        0.181824  -1.5478   0.465328
source
ReservoirComputing.pseudo_svdFunction
pseudo_svd([rng], [T], dims...; 
    max_value=1.0, sparsity=0.1, sorted=true, reverse_sort=false,
    return_sparse=false)

Returns an initializer to build a sparse reservoir matrix with the given sparsity by using a pseudo-SVD approach as described in (Yang et al., 2018).

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 reservoir matrix.

Keyword arguments

  • max_value: The maximum absolute value of elements in the matrix. Default is 1.0
  • sparsity: The desired sparsity level of the reservoir matrix. Default is 0.1
  • sorted: A boolean indicating whether to sort the singular values before creating the diagonal matrix. Default is true.
  • reverse_sort: A boolean indicating whether to reverse the sorted singular values. Default is false.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • return_diag: flag for returning a Diagonal matrix. If both return_diag and return_sparse are set to true priority is given to return_diag. Default is false.

Examples

julia> res_matrix = pseudo_svd(5, 5)
5×5 Matrix{Float32}:
 0.306998  0.0       0.0       0.0       0.0
 0.0       0.325977  0.0       0.0       0.0
 0.0       0.0       0.549051  0.0       0.0
 0.0       0.0       0.0       0.726199  0.0
 0.0       0.0       0.0       0.0       1.0
source
ReservoirComputing.chaotic_initFunction
chaotic_init([rng], [T], dims...;
    extra_edge_probability=T(0.1), spectral_radius=one(T),
    return_sparse=false)

Construct a chaotic reservoir matrix using a digital chaotic system (Xie et al., 2024).

The matrix topology is derived from a strongly connected adjacency matrix based on a digital chaotic system operating at finite precision. If the requested matrix order does not exactly match a valid order the closest valid order is used.

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 reservoir matrix.

Keyword arguments

  • extra_edge_probability: Probability of adding extra random edges in the adjacency matrix to enhance connectivity. Default is 0.1.
  • desired_spectral_radius: The target spectral radius for the reservoir matrix. Default is one.
  • return_sparse: If true, the function returns the reservoir matrix as a sparse matrix. Default is false.

Examples

julia> res_matrix = chaotic_init(8, 8)
┌ Warning: 
│ 
│     Adjusting reservoir matrix order:
│         from 8 (requested) to 4
│     based on computed bit precision = 1. 
│ 
└ @ ReservoirComputing ~/.julia/dev/ReservoirComputing/src/esn/esn_inits.jl:805
4×4 SparseArrays.SparseMatrixCSC{Float32, Int64} with 6 stored entries:
   ⋅        -0.600945   ⋅          ⋅ 
   ⋅          ⋅        0.132667   2.21354
   ⋅        -2.60383    ⋅        -2.90391
 -0.578156    ⋅         ⋅          ⋅
source
ReservoirComputing.low_connectivityFunction
low_connectivity([rng], [T], dims...;
                 return_sparse = false, connected=false,
                 in_degree = 1, radius = 1.0, cut_cycle = false)

Construct an internal reservoir connectivity matrix with low connectivity.

This function creates a square reservoir matrix with the specified in-degree for each node (Griffith et al., 2019). When in_degree is 1, the function can enforce a fully connected cycle if connected is true; otherwise, it generates a random connectivity pattern.

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 reservoir matrix.

Keyword Arguments

  • return_sparse: If true, the function returns the reservoir matrix as a sparse matrix. Default is false.
  • connected: For in_degree == 1, if true a connected cycle is enforced. Default is false.
  • in_degree: The number of incoming connections per node. Must not exceed the number of nodes. Default is 1.
  • radius: The desired spectral radius of the reservoir. Defaults to 1.0.
  • cut_cycle: If true, removes one edge from the cycle to cut it. Default is false.
source
ReservoirComputing.delay_lineFunction
delay_line([rng], [T], dims...;
    weight=0.1, return_sparse=false,
    kwargs...)

Create and return a delay line reservoir matrix (Rodan and Tino, 2011).

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 reservoir matrix.

Keyword arguments

  • 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 lenght of the array matches the lenght of the sub-diagonal you want to populate. Default is 0.1.
  • shift: delay line shift. Default is 1.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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_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.0

julia> res_matrix = delay_line(5, 5; 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.0
source
ReservoirComputing.delay_line_backwardFunction
delay_line_backward([rng], [T], dims...;
    weight=0.1, fb_weight=0.1, return_sparse=false,
    delay_kwargs=(), fb_kwargs=())

Create a delay line backward reservoir with the specified by dims and weights. Creates a matrix with backward connections as described in (Rodan and Tino, 2011).

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 reservoir matrix.

Keyword arguments

  • weight: The weight determines the absolute value of forward 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 lenght of the array matches the lenght of the sub-diagonal you want to populate. Default is 0.1

  • fb_weight: Determines the absolute value of backward 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 lenght of the array matches the lenght of the sub-diagonal you want to populate. Default is 0.1.

  • fb_shift: How far the backward connection will be from the diagonal. Default is 2.

  • return_sparse: flag for returning a sparse matrix. Default is false.

  • delay_kwargs and fb_kwargs: named tuples that control the kwargs for the delay line weight and feedback weights respectively. The kwargs are as follows:

    • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
    • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
    • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
    • start: Which place after the decimal point the counting starts for the irrational sign 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_matrix = delay_line_backward(5, 5)
5×5 Matrix{Float32}:
 0.0  0.1  0.0  0.0  0.0
 0.1  0.0  0.1  0.0  0.0
 0.0  0.1  0.0  0.1  0.0
 0.0  0.0  0.1  0.0  0.1
 0.0  0.0  0.0  0.1  0.0

julia> res_matrix = delay_line_backward(Float16, 5, 5)
5×5 Matrix{Float16}:
 0.0  0.1  0.0  0.0  0.0
 0.1  0.0  0.1  0.0  0.0
 0.0  0.1  0.0  0.1  0.0
 0.0  0.0  0.1  0.0  0.1
 0.0  0.0  0.0  0.1  0.0
source
ReservoirComputing.simple_cycleFunction
simple_cycle([rng], [T], dims...; 
    weight=0.1, return_sparse=false,
    kwargs...)

Create a simple cycle reservoir (Rodan and Tino, 2011).

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 reservoir matrix.

Keyword arguments

  • weight: Weight of the connections in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the cycle you want to populate. Default is 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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_matrix = simple_cycle(5, 5)
5×5 Matrix{Float32}:
 0.0  0.0  0.0  0.0  0.1
 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

julia> res_matrix = simple_cycle(5, 5; weight = 11)
5×5 Matrix{Float32}:
  0.0   0.0   0.0   0.0  11.0
 11.0   0.0   0.0   0.0   0.0
  0.0  11.0   0.0   0.0   0.0
  0.0   0.0  11.0   0.0   0.0
  0.0   0.0   0.0  11.0   0.0
source
ReservoirComputing.cycle_jumpsFunction
cycle_jumps([rng], [T], dims...; 
    cycle_weight=0.1, jump_weight=0.1, jump_size=3, return_sparse=false,
    cycle_kwargs=(), jump_kwargs=())

Create a cycle jumps reservoir (Rodan and Tiňo, 2012).

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 reservoir matrix.

Keyword arguments

  • cycle_weight: The weight of cycle connections. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the cycle you want to populate. Default is 0.1.

  • jump_weight: The weight of jump connections. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the jumps you want to populate. Default is 0.1.

  • jump_size: The number of steps between jump connections. Default is 3.

  • return_sparse: flag for returning a sparse matrix. Default is false.

  • cycle_kwargs and jump_kwargs: named tuples that control the kwargs for the cycle and jump weights respectively. The kwargs are as follows:

    • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
    • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
    • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
    • start: Which place after the decimal point the counting starts for the irrational sign 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_matrix = cycle_jumps(5, 5)
5×5 Matrix{Float32}:
 0.0  0.0  0.0  0.1  0.1
 0.1  0.0  0.0  0.0  0.0
 0.0  0.1  0.0  0.0  0.0
 0.1  0.0  0.1  0.0  0.0
 0.0  0.0  0.0  0.1  0.0

julia> res_matrix = cycle_jumps(5, 5; jump_size = 2)
5×5 Matrix{Float32}:
 0.0  0.0  0.1  0.0  0.1
 0.1  0.0  0.0  0.0  0.0
 0.1  0.1  0.0  0.0  0.1
 0.0  0.0  0.1  0.0  0.0
 0.0  0.0  0.1  0.1  0.0
source
ReservoirComputing.double_cycleFunction
double_cycle([rng], [T], dims...; 
    cycle_weight=0.1, second_cycle_weight=0.1,
    return_sparse=false)

Creates a double cycle reservoir (Fu et al., 2023).

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 reservoir matrix.

Keyword arguments

  • cycle_weight: Weight of the upper cycle connections in the reservoir matrix. Default is 0.1.
  • second_cycle_weight: Weight of the lower cycle connections in the reservoir matrix. Default is 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.

Examples

julia> reservoir_matrix = double_cycle(5, 5; cycle_weight = 0.1, second_cycle_weight = 0.3)
5×5 Matrix{Float32}:
 0.0  0.3  0.0  0.0  0.3
 0.1  0.0  0.3  0.0  0.0
 0.0  0.1  0.0  0.3  0.0
 0.0  0.0  0.1  0.0  0.3
 0.1  0.0  0.0  0.1  0.0
source
ReservoirComputing.true_double_cycleFunction
true_double_cycle([rng], [T], dims...; 
    cycle_weight=0.1, second_cycle_weight=0.1,
    return_sparse=false)

Creates a true double cycle reservoir, ispired by (Fu et al., 2023), with cycles built on the definition by (Rodan and Tino, 2011).

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 reservoir matrix.

Keyword arguments

  • cycle_weight: Weight of the upper cycle connections in the reservoir matrix. Default is 0.1.

  • second_cycle_weight: Weight of the lower cycle connections in the reservoir matrix. Default is 0.1.

  • return_sparse: flag for returning a sparse matrix. Default is false.

  • cycle_kwargs, and second_cycle_kwargs: named tuples that control the kwargs for the weights generation. The kwargs are as follows:

    • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
    • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
    • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
    • start: Which place after the decimal point the counting starts for the irrational sign 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> true_double_cycle(5, 5; cycle_weight = 0.1, second_cycle_weight = 0.3)
5×5 Matrix{Float32}:
 0.0  0.3  0.0  0.0  0.1
 0.1  0.0  0.3  0.0  0.0
 0.0  0.1  0.0  0.3  0.0
 0.0  0.0  0.1  0.0  0.3
 0.3  0.0  0.0  0.1  0.0
source
ReservoirComputing.selfloop_cycleFunction
selfloop_cycle([rng], [T], dims...; 
    cycle_weight=0.1, selfloop_weight=0.1,
    return_sparse=false, kwargs...)

Creates a simple cycle reservoir with the addition of self loops (Elsarraj et al., 2019).

This architecture is referred to as TP1 in the original paper.

Equations

\[W_{i,j} = \begin{cases} ll, & \text{if } i = j \\ r, & \text{if } j = i - 1 \text{ for } i = 2 \dots N \\ r, & \text{if } i = 1, j = N \\ 0, & \text{otherwise} \end{cases}\]

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 reservoir matrix.

Keyword arguments

  • cycle_weight: Weight of the cycle connections in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the cycle you want to populate. Default is 0.1.
  • selfloop_weight: Weight of the self loops in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the diagonal you want to populate. Default is 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> reservoir_matrix = selfloop_cycle(5, 5)
5×5 Matrix{Float32}:
 0.1  0.0  0.0  0.0  0.1
 0.1  0.1  0.0  0.0  0.0
 0.0  0.1  0.1  0.0  0.0
 0.0  0.0  0.1  0.1  0.0
 0.0  0.0  0.0  0.1  0.1

julia> reservoir_matrix = selfloop_cycle(5, 5; weight=0.2, selfloop_weight=0.5)
5×5 Matrix{Float32}:
 0.5  0.0  0.0  0.0  0.2
 0.2  0.5  0.0  0.0  0.0
 0.0  0.2  0.5  0.0  0.0
 0.0  0.0  0.2  0.5  0.0
 0.0  0.0  0.0  0.2  0.5
source
ReservoirComputing.selfloop_feedback_cycleFunction
selfloop_feedback_cycle([rng], [T], dims...; 
    cycle_weight=0.1, selfloop_weight=0.1,
    return_sparse=false)

Creates a cycle reservoir with feedback connections on even neurons and self loops on odd neurons (Elsarraj et al., 2019).

This architecture is referred to as TP2 in the original paper.

Equations

\[W_{i,j} = \begin{cases} r, & \text{if } j = i - 1 \text{ for } i = 2 \dots N \\ r, & \text{if } i = 1, j = N \\ ll, & \text{if } i = j \text{ and } i \text{ is odd} \\ r, & \text{if } j = i + 1 \text{ and } i \text{ is even}, i \neq N \\ 0, & \text{otherwise} \end{cases}\]

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 reservoir matrix.

Keyword arguments

  • cycle_weight: Weight of the cycle connections in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the cycle you want to populate. Default is 0.1.
  • selfloop_weight: Weight of the self loops in the reservoir matrix. Default is 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.

Examples

julia> reservoir_matrix = selfloop_feedback_cycle(5, 5)
5×5 Matrix{Float32}:
 0.1  0.1  0.0  0.0  0.1
 0.1  0.0  0.0  0.0  0.0
 0.0  0.1  0.1  0.1  0.0
 0.0  0.0  0.1  0.0  0.0
 0.0  0.0  0.0  0.1  0.1

julia> reservoir_matrix = selfloop_feedback_cycle(5, 5; self_loop_weight=0.5)
5×5 Matrix{Float32}:
 0.5  0.1  0.0  0.0  0.1
 0.1  0.0  0.0  0.0  0.0
 0.0  0.1  0.5  0.1  0.0
 0.0  0.0  0.1  0.0  0.0
 0.0  0.0  0.0  0.1  0.5
source
ReservoirComputing.selfloop_delayline_backwardFunction
selfloop_delayline_backward([rng], [T], dims...; 
    weight=0.1, selfloop_weight=0.1, fb_weight=0.1,
    fb_shift=2, return_sparse=false, fb_kwargs=(),
    selfloop_kwargs=(), delay_kwargs=())

Creates a reservoir based on a delay line with the addition of self loops and backward connections shifted by one (Elsarraj et al., 2019).

This architecture is referred to as TP3 in the original paper.

Equations

\[W_{i,j} = \begin{cases} ll, & \text{if } i = j \text{ for } i = 1 \dots N \\ r, & \text{if } j = i - 1 \text{ for } i = 2 \dots N \\ r, & \text{if } j = i - 2 \text{ for } i = 3 \dots N \\ 0, & \text{otherwise} \end{cases}\]

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 reservoir matrix.

Keyword arguments

  • weight: Weight of the cycle connections in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the cycle you want to populate. Default is 0.1.
  • selfloop_weight: Weight of the self loops in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the diagonal you want to populate. Default is 0.1.
  • fb_weight: Weight of the feedback in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the diagonal you want to populate. Default is 0.1.
  • fb_shift: How far the backward connection will be from the diagonal. Default is 2.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • delay_kwargs, selfloop_kwargs, and fb_kwargs: named tuples that control the kwargs for the weights generation. The kwargs are as follows:
    • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
      • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
      • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
      • start: Which place after the decimal point the counting starts for the irrational sign 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> reservoir_matrix = selfloop_delayline_backward(5, 5)
5×5 Matrix{Float32}:
 0.1  0.0  0.1  0.0  0.0
 0.1  0.1  0.0  0.1  0.0
 0.0  0.1  0.1  0.0  0.1
 0.0  0.0  0.1  0.1  0.0
 0.0  0.0  0.0  0.1  0.1

julia> reservoir_matrix = selfloop_delayline_backward(5, 5; weight=0.3)
5×5 Matrix{Float32}:
 0.1  0.0  0.3  0.0  0.0
 0.3  0.1  0.0  0.3  0.0
 0.0  0.3  0.1  0.0  0.3
 0.0  0.0  0.3  0.1  0.0
 0.0  0.0  0.0  0.3  0.1
source
ReservoirComputing.selfloop_forward_connectionFunction
selfloop_forward_connection([rng], [T], dims...; 
    weight=0.1, selfloop_weight=0.1,
    return_sparse=false, selfloop_kwargs=(),
    delay_kwargs=())

Creates a reservoir based on a forward connection of weights between even nodes with the addition of self loops (Elsarraj et al., 2019).

This architecture is referred to as TP4 in the original paper.

Equations

\[W_{i,j} = \begin{cases} ll, & \text{if } i = j \text{ for } i = 1 \dots N \\ r, & \text{if } j = i - 2 \text{ for } i = 3 \dots N \\ 0, & \text{otherwise} \end{cases}\]

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 reservoir matrix.

Keyword arguments

  • weight: Weight of the cycle connections in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the cycle you want to populate. Default is 0.1.
  • selfloop_weight: Weight of the self loops in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the diagonal you want to populate. Default is 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • delay_kwargs and selfloop_kwargs: named tuples that control the kwargs for the delay line weight and self loop weights respectively. The kwargs are as follows:
    • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
      • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
      • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
      • start: Which place after the decimal point the counting starts for the irrational sign 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> reservoir_matrix = selfloop_forward_connection(5, 5)
5×5 Matrix{Float32}:
 0.1  0.0  0.0  0.0  0.0
 0.0  0.1  0.0  0.0  0.0
 0.1  0.0  0.1  0.0  0.0
 0.0  0.1  0.0  0.1  0.0
 0.0  0.0  0.1  0.0  0.1

julia> reservoir_matrix = selfloop_forward_connection(5, 5; weight=0.5)
5×5 Matrix{Float32}:
 0.1  0.0  0.0  0.0  0.0
 0.0  0.1  0.0  0.0  0.0
 0.5  0.0  0.1  0.0  0.0
 0.0  0.5  0.0  0.1  0.0
 0.0  0.0  0.5  0.0  0.1
source
ReservoirComputing.forward_connectionFunction
forward_connection([rng], [T], dims...; 
    weight=0.1, selfloop_weight=0.1,
    return_sparse=false)

Creates a reservoir based on a forward connection of weights (Elsarraj et al., 2019).

This architecture is referred to as TP5 in the original paper.

Equations

\[W_{i,j} = \begin{cases} r, & \text{if } j = i - 2 \text{ for } i = 3 \dots N \\ 0, & \text{otherwise} \end{cases}\]

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 reservoir matrix.

Keyword arguments

  • weight: Weight of the cycle connections in the reservoir matrix. This can be provided as a single value or an array. In case it is provided as an array please make sure that the lenght of the array matches the lenght of the sub-diagonal you want to populate. Default is 0.1.
  • return_sparse: flag for returning a sparse matrix. Default is false.
  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> reservoir_matrix = forward_connection(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.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

julia> reservoir_matrix = forward_connection(5, 5; weight=0.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.5  0.0  0.0  0.0  0.0
 0.0  0.5  0.0  0.0  0.0
 0.0  0.0  0.5  0.0  0.0
source

Building functions

ReservoirComputing.scale_radius!Function
scale_radius!(matrix, radius)

Scale the spectral radius of the given matrix to be equal to the given radius

Arguments

  • matrix: Matrix to be scaled.
  • radius: desidered radius to scale the given matrix to
source
ReservoirComputing.delay_line!Function
delay_line!([rng], reservoir_matrix, weight, shift;
    sampling_type=:no_sample, irrational=pi, start=1,
    p=0.5)

Adds a delay line in the reservoir_matrix, with given shift and weight. The weight can be a single number or an array.

Arguments

  • rng: Random number generator. Default is Utils.default_rng() from WeightInitializers.
  • reservoir_matrix: matrix to be changed.
  • weight: weight to add as a delay line. Can be either a single number or an array.
  • shift: How far the delay line will be from the diagonal.

Keyword arguments

  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> 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> delay_line!(matrix, 5.0, 2)
5×5 Matrix{Float32}:
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 5.0  0.0  0.0  0.0  0.0
 0.0  5.0  0.0  0.0  0.0
 0.0  0.0  5.0  0.0  0.0

 julia> delay_line!(matrix, 5.0, 2; sampling_type=:bernoulli_sample!)
5×5 Matrix{Float32}:
 0.0   0.0  0.0  0.0  0.0
 0.0   0.0  0.0  0.0  0.0
 5.0   0.0  0.0  0.0  0.0
 0.0  -5.0  0.0  0.0  0.0
 0.0   0.0  5.0  0.0  0.0
source
ReservoirComputing.backward_connection!Function
backward_connection!([rng], reservoir_matrix, weight, shift;
    sampling_type=:no_sample, irrational=pi, start=1,
    p=0.5)

Adds a backward connection in the reservoir_matrix, with given shift and weight. The weight can be a single number or an array.

Arguments

  • rng: Random number generator. Default is Utils.default_rng() from WeightInitializers.
  • reservoir_matrix: matrix to be changed.
  • weight: weight to add as a backward connection. Can be either a single number or an array.
  • shift: How far the backward connection will be from the diagonal.

Keyword arguments

  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> 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> backward_connection!(matrix, 3.0, 1)
5×5 Matrix{Float32}:
 0.0  3.0  0.0  0.0  0.0
 0.0  0.0  3.0  0.0  0.0
 0.0  0.0  0.0  3.0  0.0
 0.0  0.0  0.0  0.0  3.0
 0.0  0.0  0.0  0.0  0.0

julia> backward_connection!(matrix, 3.0, 1; sampling_type = :bernoulli_sample!)
5×5 Matrix{Float32}:
 0.0  3.0   0.0  0.0   0.0
 0.0  0.0  -3.0  0.0   0.0
 0.0  0.0   0.0  3.0   0.0
 0.0  0.0   0.0  0.0  -3.0
 0.0  0.0   0.0  0.0   0.0
source
ReservoirComputing.simple_cycle!Function
simple_cycle!([rng], reservoir_matrix, weight;
    sampling_type=:no_sample, irrational=pi, start=1,
    p=0.5)

Adds a simple cycle in the reservoir_matrix, with given weight. The weight can be a single number or an array.

Arguments

  • rng: Random number generator. Default is Utils.default_rng() from WeightInitializers.
  • reservoir_matrix: matrix to be changed.
  • weight: weight to add as a simple cycle. Can be either a single number or an array.

Keyword arguments

  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> 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> simple_cycle!(matrix, 1.0; sampling_type = :irrational_sample!)
5×5 Matrix{Float32}:
  0.0  0.0   0.0   0.0  -1.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.0
source
ReservoirComputing.reverse_simple_cycle!Function
reverse_simple_cycle!([rng], reservoir_matrix, weight;
    sampling_type=:no_sample, irrational=pi, start=1,
    p=0.5)

Adds a reverse simple cycle in the reservoir_matrix, with given weight. The weight can be a single number or an array.

Arguments

  • rng: Random number generator. Default is Utils.default_rng() from WeightInitializers.
  • reservoir_matrix: matrix to be changed.
  • weight: weight to add as a simple cycle. Can be either a single number or an array.

Keyword arguments

  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> 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> reverse_simple_cycle!(matrix, 1.0; sampling_type = :regular_sample!)
5×5 Matrix{Float32}:
 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
 1.0   0.0  0.0   0.0  0.0
source
ReservoirComputing.self_loop!Function
self_loop!([rng], reservoir_matrix, weight, jump_size;
    sampling_type=:no_sample, irrational=pi, start=1,
    positive_prob=0.5)

Adds jumps to a given reservoir_matrix with chosen weight and determined jump_size. weight can be either a number or an array.

Arguments

  • rng: Random number generator. Default is Utils.default_rng() from WeightInitializers.
  • 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

  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> 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)
5×5 Matrix{Float32}:
  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.0
  0.0  0.0   0.0   0.0   1.0
source
ReservoirComputing.add_jumps!Function
add_jumps!([rng], reservoir_matrix, weight, jump_size;
    sampling_type=:no_sample, irrational=pi, start=1,
    positive_prob=0.5)

Adds jumps to a given reservoir_matrix with chosen weight and determined jump_size. weight can be either a number or an array.

Arguments

  • rng: Random number generator. Default is Utils.default_rng() from WeightInitializers.
  • reservoir_matrix: matrix to be changed.
  • weight: weight to add as a simple cycle. Can be either a single number or an array.
  • jump_size: size of the jump's distance.

Keyword arguments

  • sampling_type: Sampling that decides the distribution of weight negative numbers. If set to :no_sample the sign is unchanged. If set to :bernoulli_sample! then each weight can be positive with a probability set by positive_prob. If set to :irrational_sample! the weight is 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 chosen strides. strides can be a single number or an array. Default is :no_sample.
  • positive_prob: probability of the weight being positive when sampling_type is set to :bernoulli_sample!. Default is 0.5.
  • irrational: Irrational number whose decimals decide the sign of weight. Default is pi.
  • start: Which place after the decimal point the counting starts for the irrational sign 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> 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> add_jumps!(matrix, 1.0)
5×5 Matrix{Float32}:
  0.0  0.0   1.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  0.0   0.0   0.0   1.0
  0.0  0.0   1.0   0.0   0.0
source

References