aai-institute / continuiti

Learning function operators with neural networks.
GNU Lesser General Public License v3.0
19 stars 3 forks source link

Feature: Fourier Layer for Fourier Neural Operator #78

Closed MLuchmann closed 5 months ago

MLuchmann commented 6 months ago

Feature: Fourier Neural operator

Description

Implementation of the Fourier Neural Operator.

References

https://arxiv.org/abs/2010.08895

Which issue does this PR tackle?

How does it solve the problem?

How are the changes tested?

Checklist for Contributors

Checklist for Reviewers:

MLuchmann commented 6 months ago

Hey @samuelburbulla,

this is a draft for the Fourier layer in N-dimensions. I kept the 1d implementation in there for now because its a bit easier to understand.

I added a few tests (test_fourierlayer.py) (for a 1d example and a 2d example). I implemented two tests. One simply checks whether the FFT works as expected ( = convolutional operation in real-space). The other just trains an operator and checks the MSE.

I also added a notebook to play around with the operators. I experimented with different input functions. However, I tried to avoid the sin / cos examples because I was worried that the frequency spectrum could cause issues. The Fourier transformed sin-function should give a delta distribution. Because we use the FFT and not the continuous FT, this only leads to a peak at some freququency. Still, for the notebook I wanted to have a more regular frequency spectrum.

However, I am stuck right now. While the 1d example works very well, the 2D example is quite bad. While it does learn something, I don't manage to improve the performance. I tried to stack several layer on top of each other (see notebook) and also played around with the hyperparameters. It could be an issue with the implementation but I am not sure. What do you think? I implemented the tests for that reason but they only taught me that their are boundary effects when performing a convolution...

Edit: This is solved now. The 1d and 2d case work now as expected and give reasonable performance.

MLuchmann commented 5 months ago

Hi @samuelburbulla , this is the current implementation the FourierLayer. I think it could be merged in this state. Feel free to move around or change things. What do you think?

samuelburbulla commented 5 months ago

Thanks, @MLuchmann, looks good!

I cleaned up a little bit and will merge the Fourier layer first, there are quite some conflicts with the main. Afterwards, I will add a true FNO and convert your notebook to an example.