pygsp icon indicating copy to clipboard operation
pygsp copied to clipboard

inverse method not working for any filter

Open mfarazi1991 opened this issue 4 years ago • 4 comments

Hi,

I cannot use the inverse method of filterbanks. I did use the exact codes in the commented part of the inverse method in python files and still get the following error:

AttributeError: 'Abspline' object has no attribute 'inverse'

mfarazi1991 avatar Sep 28 '21 03:09 mfarazi1991

Hi, thanks for your interest! You may be using an older version. Try to install the latest from github with pip install git+https://github.com/epfl-lts2/pygsp. (Discussion in #69.)

mdeff avatar Sep 28 '21 04:09 mdeff

I'm on the latest version and also facing the same issue.

I'm also a little confused with the way the package works. If I understand correctly, given a wavelet filter g, g.filter(signal) should give the wavelet coefficients c, and g.inverse(c) should reconstruct the signal, right?

chiragvshukla avatar Nov 02 '21 15:11 chiragvshukla

To inverse coefficient, you have to use the synthesize function. Synthesis is actually the inverse of analysis (analyze is actually the same as filter). The inverse function returns another filter, and does not inverse the coefficients.

Here is untested pseudo code:

signal = np.random.randn(G.N,1)
inverse_filter = g.inverse()
coefs = g.analyze(signal)
reconstructed_signal = inverse_filter.synthesize(coefs)
np.linalg.norm(reconstructed_signal-signal)

Good luck

nperraud avatar Nov 02 '21 18:11 nperraud

Thanks for the pseudo-code and the explanation! The problem still remains in calculating in inverse filter though, since it gives the "object has no attribute 'inverse' " error. Is there a workaround for this?

chiragvshukla avatar Nov 02 '21 18:11 chiragvshukla