pseudo_svd

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. true requires SparseArrays to be loaded. 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

Default call:

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

With reversed sorting:

julia> pseudo_svd(5, 5; reverse_sort = true)
5×5 Matrix{Float32}:
 1.0  0.0       0.0       0.0       0.0
 0.0  0.726199  0.0       0.0       0.0
 0.0  0.0       0.549051  0.0       0.0
 0.0  0.0       0.0       0.325977  0.0
 0.0  0.0       0.0       0.0       0.306998

With no sorting

julia> pseudo_svd(5, 5; sorted = false)
5×5 Matrix{Float32}:
 0.726199  0.0       0.0       0.0       0.0
 0.0       0.325977  0.0       0.0       0.0
 0.0       0.0       0.306998  0.0       0.0
 0.0       0.0       0.0       0.549051  0.0
 0.0       0.0       0.0       0.0       0.788919

Returning as a Diagonal or a sparse matrix:

julia> pseudo_svd(5, 5; return_diag = true)
5×5 LinearAlgebra.Diagonal{Float32, Vector{Float32}}:
 0.306998   ⋅         ⋅         ⋅         ⋅
  ⋅        0.325977   ⋅         ⋅         ⋅
  ⋅         ⋅        0.549051   ⋅         ⋅
  ⋅         ⋅         ⋅        0.726199   ⋅
  ⋅         ⋅         ⋅         ⋅        1.0

julia> using SparseArrays

julia> pseudo_svd(5, 5; return_sparse = true)
5×5 SparseMatrixCSC{Float32, Int64} with 5 stored entries:
 0.306998   ⋅         ⋅         ⋅         ⋅
  ⋅        0.325977   ⋅         ⋅         ⋅
  ⋅         ⋅        0.549051   ⋅         ⋅
  ⋅         ⋅         ⋅        0.726199   ⋅
  ⋅         ⋅         ⋅         ⋅        1.0
source

References