Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of SparseArrays.jl #243

Open
MartinuzziFrancesco opened this issue Jan 15, 2025 · 1 comment
Open

Make use of SparseArrays.jl #243

MartinuzziFrancesco opened this issue Jan 15, 2025 · 1 comment

Comments

@MartinuzziFrancesco
Copy link
Collaborator

In a lot of initializers for ESNs the majority of the entries are zero (>90%). An earlier version of ReservoirComputing.jl used SparseArrays to build them, but this has since changed. It would help computation times to make full use of sparse matrices when possible. This could be also be left as a choice to the user, adding something like

#init_reservoir is any reservoir initializer here
julia> reservoir_matrix = init_reservoir(10, 10; return_sparse = true)
10×10 SparseMatrixCSC{Float32, Int64} with 10 stored entries:
          -1.16794                                                  1.03808
                             -1.25129                                  
                                         0.952151                      
                                                                      
                                                                      
                                                                     
                                                  -2.04221             
 0.599564                                                   -1.06445    
                                                                      
                   -0.826278                                           

I think the reason it was removed before had to do with the regression training, so this would need to be tested on it

@MartinuzziFrancesco
Copy link
Collaborator Author

MartinuzziFrancesco commented Jan 15, 2025

Initializers like pseudo_svd can even be represented as Diagonal

julia> reservoir_matrix = psuedo_svd(5, 5;
    return_sparse = false, #users may still need a sparse matrix
    return_diag = true) #would need a check that both aren't true at the same time
5×5 Diagonal{Float32, Vector{Float32}}:
 0.306998                               
          0.325977                      
                   0.549051             
                            0.726199    
                                     1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant