Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Neural Networks learn to do Fourier Transform? [closed]

If I want to make a neural net that can compute the Fourier Transform of any input signal, what should be the architecture, dataset, loss function, etc.

My way would be, making a normal fully connected NN that takes as input a signal (array vector of some size) and outputs the fourier transform (same size vector), the loss function might be a coef. error that measures how far it is from the actual fourier transform (maybe dynamic time warping). any suggestions would be appreciated.

like image 801
Amine Chadi Avatar asked Nov 02 '25 18:11

Amine Chadi


2 Answers

As others have mentioned, a neural network trained to do the discrete Fourier transform (DFT) will likely work out to be an imperfect approximation of the Fourier transform and much slower than a good Fast Fourier Transform implementation. So think about whether this is worthwhile for you want to accomplish.

That said, a straightforward approach would be a single dense layer, without bias term, and using linear activation, and mean squared error for the training loss. In an ideal world, the layer's weight matrix would converge to the DFT matrix, then the network would exactly reproduce the discrete Fourier transform. But because of limitations with dataset and optimization, don't expect to get there exactly. Here is a github gist where someone tried that, including a lot of plots and interesting discussion about how successful this was:

endolith - Training neural network to implement discrete Fourier transform (DFT/FFT)

like image 124
Pascal Getreuer Avatar answered Nov 04 '25 08:11

Pascal Getreuer


The Fourier Transform relies on its kernels being defined with extreme precision at each point, float32, 64, and beyond, which makes most NNs, which are approximators, horrible candidates. It's also not exactly productive to learn what's already been perfected, unless for some feature extraction study.

The FT kernel has, however, been utilized as a mechanism, just like activation functions, in Fourier Neural Operator for Parametric Partial Differential Equations, with promising results:

enter image description here

Regardless, such a design question is better suited for Data Science or AI networks, and try being more specific with what you seek to accomplish.

like image 33
OverLordGoldDragon Avatar answered Nov 04 '25 10:11

OverLordGoldDragon