Skip to content

Commit f1236b6

Browse files
committed
Update README and fixed imports
1 parent b483eca commit f1236b6

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

sfno/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spatiotemporal Fourier Neural Operator
22

33
## Learning maps between Bochner spaces
4-
- SFNO now can learn a `trajectory-to-trajectory` map that inputs arbitrary-length trajectory, and outputs arbitrary-lengthed trajectory (if length is not specified, then the output length is the same with the input).
4+
SFNO now can learn a `trajectory-to-trajectory` map that inputs arbitrary-length trajectory, and outputs arbitrary-lengthed trajectory (if length is not specified, then the output length is the same with the input).
55

66
## Data generation
77

sfno/finetune.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
import torch.fft as fft
1616
import torch.nn as nn
1717

18-
try:
19-
from .sfno import OutConv, SpectralConvT
20-
except:
21-
from sfno import OutConv, SpectralConvT
18+
from .sfno import OutConv, SpectralConvT
2219
from data_gen.solvers import *
2320
from einops import rearrange, repeat
2421

sfno/fno3d.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
"""
22
minor modification from the original FNO3d code:
3+
Note: the original code is from the master branch of the neural operator repo
4+
However, as of Aug 2024, the master branch has been deleted by the maintainers.
35
https://github.com/neuraloperator/neuraloperator/blob/master/fourier_3d.py
6+
For an unchanged fork please
7+
https://github.com/scaomath/fourier_neural_operator/blob/master/fourier_3d.py
8+
which is update-to-date till the commit de514f2 with shasum
9+
de514f2adc0de483f99253d9c6630e1fb6e653f1
10+
https://github.com/scaomath/fourier_neural_operator/commit/de514f2adc0de483f99253d9c6630e1fb6e653f1
411
"""
512

613
import torch

sfno/sfno.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,8 @@ def __init__(
545545
super().__init__()
546546

547547
"""
548-
The overall network reimplemented for scalar field of NSE-like equations
549-
550-
It contains num_spectral_layers (=4 by default) layers of the Fourier layer.
548+
The overall network reimplemented to model (2+1)D spatiotemporal PDEs of
549+
a scalar field/vector fields of NSE-like equations.
551550
552551
Major architectural differences:
553552
@@ -562,13 +561,27 @@ def __init__(
562561
3. n layers of the integral operators u' = (W + K)(u).
563562
W defined by self.w; K defined by self.conv.
564563
565-
Several key hyper-params that is different from FNO3d:
564+
Hyper-params:
565+
- mode_x, mode_y, mode_t: the number of Fourier modes in the x, y, t dimensions
566+
- width: the number of channels in the latent space
567+
- num_spectral_layers: the number of spectral conv layers, the first layer is in the lifting operator
568+
- spatial_padding: the padding size in the spatial dimensions
569+
- temporal_padding: whether to pad the temporal dimension, by default it is True, recommended to keep it True to avoid aliasing error
570+
- out_steps: the number of output time steps, if None, it will be set to the temporal dimension of the input
571+
- activation: the activation function, users provide string that directly pulls from nn. default: ReLU
572+
- lift_activation: whether to use activation in the lifting operator
573+
- spatial_random_feats: whether to use spatial random features in the lifting operator
574+
- channel_expansion: the number of channels in the MLP, default: 128
575+
576+
Grid information:
577+
- diam: the diameter of the domain, only used in the Helmholtz decomposition
578+
- n_grid: the grid size of the training data, only needed for building the fft mesh for the Helmholtz decompostion, in the forward pass the size is arbitrary (if different from the n_grid, Helmholtz layer will re-build the fft mesh, which introduces a tiny overhead)
566579
580+
Several key hyper-params that is different from FNO3d:
567581
- beta: the exponential scaling factor for the time PE, ideally it should match the a priori estimate the energy of the NSE
568582
- delta: the strength of the final skip-connection.
569583
- latent steps: the number of time steps in the hidden layers, this is independent of the input/output steps; chosing it >= 3/2 of input length is similar to zero padding of FFT to avoid aliasing due to non-periodic in the temporal dimension
570-
- n_grid: the grid size of the training data, only needed for building the fft mesh for the Helmholtz decompostion, in the forward pass the size is arbitrary (if different from the n_grid, Helmholtz layer will re-build the fft mesh, which introduces a tiny overhead)
571-
- dim_reduction: 1 for vorticity, 2 for velocity
584+
- dim_reduction: 1 for scalar field such as vorticity, 2 for vector field such as velocity
572585
573586
input: w(x, y, t) in the shape of (bsz, x, y, t)
574587
output: w(x, y, t) in the shape of (bsz, x, y, t)

sfno/train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from utils import *
2121
from pipeline import *
22-
from data import *
22+
from data_gen import *
2323
from datasets import BochnerDataset
2424
from losses import SobolevLoss
2525
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)