laszukdawid / PyEMD

Python implementation of Empirical Mode Decompoisition (EMD) method
https://pyemd.readthedocs.io/
Apache License 2.0
867 stars 224 forks source link

emd for pytorch code ? #161

Closed iganggang closed 1 month ago

iganggang commented 1 month ago

could it work in CUDA? I want to make it as a layer in PatchTST(a time series forecasting model) class emd(): def init(self, ): super(emd, self).init() self.emd = emd() def forward(self, x): imf1, imf2 = emd(x) return imf1, imf2

laszukdawid commented 1 month ago

What do you mean by "could it work in CUDA"? It could. Whether it's going to be faster? Unlikely. There's very little parallelization in EMD. In case of large time series, it might be performant to compute extrema and envelopes but casting data to and from gpu would take significant amount of time. The bottleneck in performance is usually the large number of sifting necessary.

iganggang commented 1 month ago

Sorry for my poor English. "Could it work in CUDA" means that EMD(x): x is a tensor(batch size, sequence length, channels). Could this function process the tensor x?

laszukdawid commented 1 month ago

EMD only works on time series. EMD wouldn't know which dimension in your tensor is time series therefore it should fail.

I don't think there's an easy solution to processing many signals at once. That's because the number of sifting iteration depends on the signal's shape and so some signals will take longer to process.