nickgeoca / cwt-tensorflow

Continuous wavelet transform (CWT) in tensorflow
Apache License 2.0
54 stars 15 forks source link

Comparison vs Haar Transform #5

Closed akaniklaus closed 6 years ago

akaniklaus commented 6 years ago

Hello, I have read a paper which utilizes Haar wavelet transform on financial data because it is much faster. We will either employ Haar transform on CPU or use your implementation at Tensorflow. As a person who doesn't know much about wavelet transform, can I please ask whether we can assume that using your implementation would be both faster and more accurate than Haar transform on CPU? Lastly, I would like to ask if it be possible for you to add a discrete wavelet transform such as Haar to your implementation?

In financial time series forecasting, different types of wavelets can be used such as Daubechies, Haar, Morlet and MexicanHat wavelets. Morlet and Daubechies wavelets are subject to aliasing problem. Mexican Hat wavelets are expensive to compute. Haar wavelets are advantageous for time series analysis since they are capable of capturing fluctuations between adjacent observations.

nickgeoca commented 6 years ago

I could add the Haar wavelet, but it would be hard to say how good it would be.

With current use of tensorflow convolution algorithm, it would be tough to say whether it would be faster than CPU. It definetly could be preformed faster on GPU, but this requires specific optimizations.

I will try to add it some time this week, but for now it will be unoptimized.

nickgeoca commented 6 years ago

Is there a program to use to compare it with?

akaniklaus commented 6 years ago

@nickgeoca Thanks a lot! You can compare with PyWavelets library. The usage seems pretty clear. https://pywavelets.readthedocs.io/en/latest/

nickgeoca commented 6 years ago

@akaniklaus , I may have misunderstood- it looks like the Haar wavelet is not meant for a Continuous Wavelet Transform (CWT), but for a Discrete Wavelet Transform (DWT). The Haar transform is defined as a DWT. The plan was to add the Haar to the CWT library, but for whatever reason it does not seem to be a continuous wavelet. It is possible to add any signal (including Haar) as the wavlet for a CWT, but other CWT libraries aren't using DWT wavelets such as Haar, so I am hesitant.

I haven't benchmarked it, but a while back I used both my CWT and that DWT library and the DWT seemed much much faster. It is probably a better bet to stick with DWT for now.

However, this repo could use some benchmarking. I'll try to do this this coming week, including DWT.

nickgeoca commented 6 years ago

Maybe this repo could benefit by adding a DWT? This could be a longer term project. What is your opinion @akaniklaus ?

akaniklaus commented 6 years ago

Since there is no other public tensorflow implementation for DWT as well and it has lots of applications, I believe that it might be good to have both CWT and DWT in your repository.

nickgeoca commented 6 years ago

@akaniklaus here are some results... Pywavelet CWT is faster on CPU. It could be b/c it is using AVX extensions and such; anyway TF is not taking advtange of a GPU. I will investigate this later. Clearly DWT is much faster.

akaniklaus commented 6 years ago

@nickgeoca Thank you very much for the analysis!