permutation_init

ReservoirComputing.permutation_initFunction
permutation_init([rng], [T], dims...;
    weight=0.1, permutation_matrix=nothing, return_sparse=false,
    radius=nothing, kwargs...)

Creates a permutation reservoir as described in (Boedecker et al., 2009), by first initializing a scaled identity (self-loops) and then applying a column permutation.

This construction yields:

\[ \widehat{W} = \lambda P\]

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 used for the initial self-loop initialization (and the magnitude of the nonzeros after permutation). Default is 0.1.
  • permutation_matrix: Optional permutation matrix to apply. If nothing, a random permutation is generated (using rng) and applied.
  • return_sparse: flag for returning a sparse matrix. true requires SparseArrays to be loaded. Default is false.
  • radius: The desired spectral radius of the reservoir. If nothing is passed, no scaling takes place. Defaults to nothing.
  • signs: Controls sign flips. Use RandomSigns, RegularSigns, or IrrationalDigitSigns. Pass nothing to leave signs unchanged. Default is nothing.

Examples

Default kwargs:

julia> reservoir_matrix = permutation_init(5, 5)
5×5 Matrix{Float32}:
 0.0  0.0  0.1  0.0  0.0
 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.0  0.0
 0.0  0.0  0.0  0.0  0.1

Changing the weights magnitudes to a different unique value:

julia> reservoir_matrix = permutation_init(5, 5; weight=0.99)
5×5 Matrix{Float32}:
 0.0   0.0   0.99  0.0   0.0
 0.0   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.0   0.0
 0.0   0.0   0.0   0.0   0.99

Changing the weights signs with different sign patterns:

julia> reservoir_matrix = permutation_init(5, 5; signs = RandomSigns())
5×5 Matrix{Float32}:
  0.0  0.1  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.0  -0.1  0.0
  0.0  0.0  0.1   0.0  0.0

Changing the weights to random numbers. Note that the length of the given array must be at least as long as the subdiagonal one wants to fill:

julia> weights = Float32[0.2, 0.4, 0.6, 0.8, 1.0];

julia> reservoir_matrix = permutation_init(MersenneTwister(123), 5, 5; weight=weights);

julia> size(reservoir_matrix) == (5, 5) && sort(reservoir_matrix[reservoir_matrix .!= 0]) == weights
true

Returning a sparse matrix:

julia> reservoir_matrix = permutation_init(5, 5; return_sparse=true)
5×5 SparseMatrixCSC{Float32, Int64} with 5 stored entries:
  ⋅    ⋅   0.1   ⋅    ⋅
  ⋅    ⋅    ⋅   0.1   ⋅
  ⋅   0.1   ⋅    ⋅    ⋅
 0.1   ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅   0.1
source

References

  • Boedecker, J.; Obst, O.; Mayer, N. M. and Asada, M. (2009). Studies on reservoir initialization and dynamics shaping in echo state networks. In: ESANN.