Skip to content

Commit c8d7d10

Browse files
committed
rename sfno folder to fno to avoid ModuleNotFoundError
1 parent f1236b6 commit c8d7d10

25 files changed

+460
-234
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The main changes are documented in the `README.md` under the [`torch_cfd` direct
1212
- All ops take into consideration the batch dimension of tensors `(b, *, n, m)` regardless of `*` dimension, for example, `(b, T, C, n, n)`, which is similar to PyTorch behavior, not a single trajectory like Google's original Jax-CFD package.
1313

1414
### Part II: Spectral-Refiner: Neural Operator-Assisted Navier-Stokes Equations simulator.
15-
- The **Spatiotemporal Fourier Neural Operator** (SFNO) is a spacetime tensor-to-tensor learner (or trajectory-to-trajectory), available in the [`sfno` directory](./sfno/). We draw inspiration from the [3D FNO in Nvidia's Neural Operator repo](https://github.com/neuraloperator/neuraloperator), as well as Temam's book on functional analysis for NSE. Major architectural changes can be found in [the documentation of the `SFNO` class](./sfno/sfno.py#L547).
15+
- The **Spatiotemporal Fourier Neural Operator** (SFNO) is a spacetime tensor-to-tensor learner (or trajectory-to-trajectory), available in the [`fno` directory](./fno). Different components of FNO have been re-implemented keeping the conciseness of the original implementation while allowing modern expansions. We draw inspiration from the [3D FNO in Nvidia's Neural Operator repo](https://github.com/neuraloperator/neuraloperator), [Transformers-based neural operators](https://github.com/thuml/Neural-Solver-Library), as well as Temam's book on functional analysis for NSE. Major architectural changes can be found in [the documentation of the `SFNO` class](./fno/sfno.py#L485).
1616
- Data generation for the meta-example of the isotropic turbulence in [McWilliams1984]. After the warmup phase, the energy spectra match the inverse cascade of Kolmogorov flow in a periodic box.
1717
- Pipelines for the *a posteriori* error estimation to fine-tune the SFNO to reach the scientific computing level of accuracy ($\le 10^{-6}$) in Bochner norm using FLOPs on par with a single evaluation, and only a fraction of FLOPs of a single `.backward()`.
1818
- [Examples](#examples) can be found below.
@@ -33,7 +33,7 @@ pip install -r requirements.txt
3333

3434
## Data
3535
The data are available at [https://huggingface.co/datasets/scaomath/navier-stokes-dataset](https://huggingface.co/datasets/scaomath/navier-stokes-dataset).
36-
Data generation instructions are available in the [SFNO folder](./sfno/).
36+
Data generation instructions are available in the [SFNO folder](./fno).
3737

3838

3939
## Examples
@@ -75,4 +75,4 @@ If you like to use `torch-cfd` please use the following [paper](https://arxiv.or
7575
I am grateful for the support from [Long Chen (UC Irvine)](https://github.com/lyc102/ifem) and
7676
[Ludmil Zikatanov (Penn State)](https://github.com/HAZmathTeam/hazmath) over the years, and their efforts in open-sourcing scientific computing codes. I also appreciate the support from the National Science Foundation (NSF) to junior researchers. I also want to thank the free A6000 credits at the SSE ML cluster from the University of Missouri.
7777

78-
For individual paper's acknowledgement please see [here](./sfno/README.md).
78+
For individual paper's acknowledgement please see [here](./fno/README.md).

examples/ex2_FNO3d_train_normalized.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [
88
{
@@ -32,12 +32,12 @@
3232
"\n",
3333
"import torch\n",
3434
"\n",
35-
"from sfno.pipeline import *\n",
36-
"from sfno.datasets import *\n",
37-
"from sfno.losses import SobolevLoss\n",
35+
"from fno.pipeline import *\n",
36+
"from fno.datasets import *\n",
37+
"from fno.losses import SobolevLoss\n",
3838
"\n",
39-
"from sfno.fno3d import FNO3d\n",
40-
"from sfno.visualizations import plot_contour_trajectory\n",
39+
"from fno.fno3d import FNO3d\n",
40+
"from fno.visualizations import plot_contour_trajectory\n",
4141
"from torch.utils.data import DataLoader\n",
4242
"\n",
4343
"from fno.utils import get_seed\n",

examples/ex2_SFNO_5ep_spectra.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -11,11 +11,11 @@
1111
"\n",
1212
"import torch\n",
1313
"\n",
14-
"from sfno.utils import get_num_params, get_seed\n",
15-
"from sfno.pipeline import *\n",
16-
"from sfno.losses import SobolevLoss\n",
17-
"from sfno.datasets import BochnerDataset\n",
18-
"from sfno.sfno import SFNO\n",
14+
"from fno.utils import get_num_params, get_seed\n",
15+
"from fno.pipeline import *\n",
16+
"from fno.losses import SobolevLoss\n",
17+
"from fno.datasets import BochnerDataset\n",
18+
"from fno.sfno import SFNO\n",
1919
"from torch.utils.data import DataLoader\n",
2020
"\n",
2121
"get_seed(42, printout=False)\n",

examples/ex2_SFNO_finetune_McWilliams2d.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
},
145145
{
146146
"cell_type": "code",
147-
"execution_count": 5,
147+
"execution_count": null,
148148
"metadata": {},
149149
"outputs": [
150150
{
@@ -163,14 +163,14 @@
163163
"vort_out_gt = vort_out_gt.unsqueeze(0).to(device)\n",
164164
"\n",
165165
"model.eval()\n",
166-
"model.add_latent_hook(\"r\")\n",
166+
"model.add_latent_hook(\"reduction\")\n",
167167
"with torch.no_grad():\n",
168168
" preds = model(vort_inp_gt)\n",
169169
" preds_no = preds.detach()\n",
170170
"print(f\"{loss_func(preds_no, vort_out_gt).item():.7e}\")\n",
171171
"\n",
172172
"\n",
173-
"v_latent = model.latent_tensors[\"r\"]"
173+
"v_latent = model.latent_tensors[\"reduction\"]"
174174
]
175175
},
176176
{

examples/ex2_SFNO_train.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 5,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
99
"import os\n",
1010
"import numpy as np\n",
1111
"\n",
1212
"import torch\n",
13-
"from sfno.utils import get_num_params, get_seed\n",
14-
"from sfno.pipeline import *\n",
15-
"from sfno.datasets import *\n",
16-
"from sfno.losses import *\n",
17-
"from sfno.sfno import SFNO\n",
18-
"from sfno.visualizations import plot_contour_trajectory\n",
13+
"from fno.utils import get_num_params, get_seed\n",
14+
"from fno.pipeline import *\n",
15+
"from fno.datasets import *\n",
16+
"from fno.losses import *\n",
17+
"from fno.sfno import SFNO\n",
18+
"from fno.visualizations import plot_contour_trajectory\n",
1919
"from torch.utils.data import DataLoader\n",
2020
"get_seed(1127825)\n",
2121
"\n",

examples/ex2_SFNO_train_fnodata.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -11,12 +11,12 @@
1111
"import numpy as np\n",
1212
"\n",
1313
"import torch\n",
14-
"from sfno.utils import get_num_params, get_seed\n",
15-
"from sfno.pipeline import *\n",
16-
"from sfno.datasets import *\n",
17-
"from sfno.losses import *\n",
18-
"from sfno.sfno import SFNO\n",
19-
"from sfno.visualizations import plot_contour_trajectory\n",
14+
"from fno.utils import get_num_params, get_seed\n",
15+
"from fno.pipeline import *\n",
16+
"from fno.datasets import *\n",
17+
"from fno.losses import *\n",
18+
"from fno.sfno import SFNO\n",
19+
"from fno.visualizations import plot_contour_trajectory\n",
2020
"from torch.utils.data import DataLoader\n",
2121
"\n",
2222
"get_seed(1127825)\n",

sfno/README.md renamed to fno/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Spatiotemporal Fourier Neural Operator
1+
# Spatiotemporal Fourier Neural Operator (SFNO)
2+
This is a new concise implementation of the Fourier Neural Operator see [`base.py`](./base.py#L172) for a template class.
23

34
## Learning maps between Bochner spaces
45
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).
@@ -37,6 +38,13 @@ Generate the isotropic turbulence in [1] with the inverse cascade frequency sign
3738

3839
## Training and evaluation scripts
3940

41+
42+
### Testing the arbitrary input and output discretization sizes (including time)
43+
Run the part below `__name__ == "__main__"` in [`sfno.py`](sfno.py)
44+
```bash
45+
>>> python fno/sfno.py
46+
```
47+
4048
### FNO NSE dataset
4149
Train SFNO for the FNO dataset:
4250
```bash
File renamed without changes.

0 commit comments

Comments
 (0)