pseudo_svd
ReservoirComputing.pseudo_svd — Function
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 isUtils.default_rng()from WeightInitializers.T: Type of the elements in the reservoir matrix. Default isFloat32.dims: Dimensions of the reservoir matrix.
Keyword arguments
max_value: The maximum absolute value of elements in the matrix. Default is 1.0sparsity: The desired sparsity level of the reservoir matrix. Default is 0.1sorted: A boolean indicating whether to sort the singular values before creating the diagonal matrix. Default istrue.reverse_sort: A boolean indicating whether to reverse the sorted singular values. Default isfalse.return_sparse: flag for returning asparsematrix.truerequiresSparseArraysto be loaded. Default isfalse.return_diag: flag for returning aDiagonalmatrix. If bothreturn_diagandreturn_sparseare set totruepriority is given toreturn_diag. Default isfalse.
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.0With 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.306998With 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.788919Returning as a Diagonal or a sparse matrix:
julia> diagonal_matrix = pseudo_svd(5, 5; return_diag = true);
julia> sparse_matrix = pseudo_svd(5, 5; return_sparse = true);
julia> diagonal_matrix isa Diagonal{Float32} && sparse_matrix isa SparseMatrixCSC{Float32} && size(diagonal_matrix) == size(sparse_matrix) == (5, 5)
trueReferences
- Yang, C.; Qiao, J.; Han, H. and Wang, L. (2018). Design of polynomial echo state networks for time series prediction. Neurocomputing 290, 148–160.