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

Memory usage reduction #94

Closed pulquero closed 3 years ago

pulquero commented 3 years ago

compute_fourier_basis uses self._e, self._U = np.linalg.eigh(self.L.toarray()) this could be replaced with scipy.linalg.eigh(self.L.toarray(), overwrite_a=True) to reuse the memory used by the output of self.L.toarray().

pulquero commented 3 years ago

Could also add a spectrum_only param to skip the eigenvectors as they aren't required for some stuff.

mdeff commented 3 years ago

Thanks for the suggestions! Reusing the memory is definitely a good idea. Care to make a PR?

I'm less sure about a spectrum_only parameter. In general, adding parameters adds complexity. In most cases, the eigendecomposition is to be avoided altogether. Which cases are you thinking about where we'd want the eigenvalues but not the eigenvectors? Also, the computational cost isn't reduced and the memory must be available for L.toarray() anyway.

pulquero commented 3 years ago

Btw, I have an implementation of graphwave (about 10 lines), if that would also be of interest.

mdeff commented 3 years ago

Let's discuss that in #97.