epfl-lts2 / pygsp

Graph Signal Processing in Python
https://pygsp.rtfd.io
BSD 3-Clause "New" or "Revised" License
483 stars 93 forks source link

Inability of handling large matrix due to dense matrix operation in Graph.compute_fourier_basis #107

Closed cby120 closed 10 months ago

cby120 commented 10 months ago

PyGSP supports sparse adjacent matrix input, however when computing fourier basis, it uses numpy.linalg.eigh and converted W to dense, which limits the capacity of matrix scale, especially sparse connections.

fourier.py - L103
    self._e, self._U = np.linalg.eigh(self.L.toarray())

Is it possible to replace it with scipy.sparse.linalg.eigsh, in order to support sparse operation and improve the ability to deal with large graphs ?

Thanks developers !

nperraud commented 10 months ago

Hi @cby120 Since we compute all eigenvalues and eigenvectors, I believe there is no gain possible with eigsh.

cby120 commented 10 months ago

Hello, @nperraud I've done some research. It seems like scipy.linalg.eigsh will return the decomposed matrix in dense format. So the results would unable to allocate memory the same as numpy.linalg.eigh. Thank you for responding. But if scipy updates new decomposition function that returns sparse-formatted results, this may help to deal with larger sparse matrices, as a potential improvement I hope. Best wishes !