VEWOXIC / FITS

FITS: Frequency Interpolation Time Series Analysis Baseline
Apache License 2.0
112 stars 13 forks source link

low pass filter in fits #14

Closed iganggang closed 1 month ago

iganggang commented 1 month ago

Dear author,

your paper is very strong. and i have read many times. but I have a question about lowpass filter in models. in the code, u use low_specx[:,self.dominance_freq:]=0 # LPF. i know some signal processing knowledge. if we just do this, it will have some problem, like endeffect. i do not look for this. there is some signal processing method, like lowpass filter, in scipy. can we use it directly? lowpass filter in scipy is based on CPU. if I add lowpass filter in scipy, will it work on GPU?

VEWOXIC commented 1 month ago

Hi. Thanks for taking interest in our work! And thanks for your insightful question.

Yes, we are also aware of some signal distortion problem with such a simple ideal filter, especially in real-life. However, with time series, we find the distortion is neglectable which causes loss way smaller than the forecasting error. Thus, we directly use such a simple filter implementation. I think adding some more carefully designed filter may indeed bring further benefits.

I am not sure if the filters from scipy would work perfectly with torch auto_grad. It may break the gradient back-propogation.

However, it is still a great idea that worth a try. Because, although the LPF is on the gradient back-propagation route, there is no other trainable-parameter before it. So, maybe it does not matter if you just stop the gradient on the LPF. But you have to find a way to do the "de-filter" process and it have to be differentiable (the zero padding in our original FITS).

Hope these can give you some clue.

iganggang commented 1 month ago

lowpass filter in Scipy does not have the Pytorch version. it does not work in CUDA. Your idea is the most effective.

iganggang commented 1 month ago

I wonder whether I can use some series decomposition method. But Pytorch does not have these functions. Tensor x before into PatchTST backbone, can I use EMD(signal processing methods) to decompose it? But EMD is run on the CPU(EMD method from Scipy only works on numpy, not tensor), how can it work on GPU? how to make EMD process tensor? such as EMD(tensor x).

VEWOXIC commented 1 month ago

Sorry, I am not very familiar with the Scipy and EMD. If you really need it, please consider if there is any other third-party pytorch implementation (I find this https://github.com/daerduoCarey/PyTorchEMD ). Or, if you are familiar with the algorithm, you can consider implementing it with pytorch.

Further, it seems that some filter are provided in the torchaudio package. Maybe you can have a check: https://pytorch.org/audio/main/tutorials/filter_design_tutorial.html

iganggang commented 1 month ago

Sorry for the abbreviation. Empirical mode decomposition(EMD) is a signal processing method that separates raw signals into several sub-signals. there is no EMD pytorch package. I am another major. Please give a suggestion should I try to write it in pytorch? or give it up? yes, thank you very much. I see the filter in the torch audio package. but it does not process Endeffect.

VEWOXIC commented 1 month ago

This really depends on whether you need it. It is your call, bro.

VEWOXIC commented 1 month ago

If there is no further question, I will close this issue. Please feel free to reopen it.