Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- neural-operator
|
| 4 |
+
- fno
|
| 5 |
+
- fourier-neural-operator
|
| 6 |
+
- darcy-flow
|
| 7 |
+
- pde
|
| 8 |
+
- cross-attention
|
| 9 |
+
- out-of-distribution
|
| 10 |
+
- scientific-machine-learning
|
| 11 |
+
license: mit
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Cross-Attention FNO for OOD Coefficient Distribution
|
| 15 |
+
|
| 16 |
+
## Model Description
|
| 17 |
+
|
| 18 |
+
This model implements a **Cross-Attention Coefficient Head** for the Fourier Neural Operator (FNO) architecture, designed to improve out-of-distribution (OOD) generalization when the coefficient field statistics shift.
|
| 19 |
+
|
| 20 |
+
### Key Innovation
|
| 21 |
+
|
| 22 |
+
Standard FNO treats the variable coefficient field `a(x)` as just another input channel (concatenated). This model instead uses a **cross-attention mechanism** where:
|
| 23 |
+
- **Queries** come from the spatial coordinate grid `[-1,1]Β²`
|
| 24 |
+
- **Keys and Values** come from the coefficient field `a(x)`
|
| 25 |
+
- A learned bypass residual preserves direct coefficient information
|
| 26 |
+
|
| 27 |
+
This forces the model to build a conditioning representation of the coefficient field rather than treating it as a fixed input feature, improving generalization when permeability statistics differ from training.
|
| 28 |
+
|
| 29 |
+
## Architecture Details
|
| 30 |
+
|
| 31 |
+
```
|
| 32 |
+
a(x) ββ[kv_embed]βββΊ KV
|
| 33 |
+
β
|
| 34 |
+
ββββΊ cross-attn βββ Q = query_proj(coordinate_grid [-1,1]Β²)
|
| 35 |
+
β
|
| 36 |
+
ββββΊ bypass = coeff_bypass(a) βββ
|
| 37 |
+
βΌ
|
| 38 |
+
attended + bypass ββ[FNO blocks]βββΊ projection βββΊ u(x)
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
### Components
|
| 42 |
+
- **Heterogeneous Cross-Attention**: GNOT-style feature-wise Q/K normalization
|
| 43 |
+
- **Fourier Layers**: Spectral convolution with learnable modes
|
| 44 |
+
- **Bypass Residual**: Direct coefficient channel for fallback
|
| 45 |
+
- **GELU Activation**: Nonlinearity between layers
|
| 46 |
+
|
| 47 |
+
### Hyperparameters (Small Config)
|
| 48 |
+
| Parameter | Value |
|
| 49 |
+
|---|---|
|
| 50 |
+
| Resolution | 32Γ32 |
|
| 51 |
+
| Width | 32 |
|
| 52 |
+
| Depth | 3 FNO blocks |
|
| 53 |
+
| Modes | 8 |
|
| 54 |
+
| Attention Heads | 4 |
|
| 55 |
+
|
| 56 |
+
### Hyperparameters (Full Config)
|
| 57 |
+
| Parameter | Value |
|
| 58 |
+
|---|---|
|
| 59 |
+
| Resolution | 64Γ64 |
|
| 60 |
+
| Width | 64 |
|
| 61 |
+
| Depth | 4 FNO blocks |
|
| 62 |
+
| Modes | 12 |
|
| 63 |
+
| Attention Heads | 4 |
|
| 64 |
+
|
| 65 |
+
## Training Data
|
| 66 |
+
|
| 67 |
+
- **PDE**: 2D Darcy flow `-βΒ·(a(x)βu) = 1` on unit square, zero Dirichlet BCs
|
| 68 |
+
- **Coefficient**: Log-Gaussian random field with isotropic covariance
|
| 69 |
+
- **Train**: Correlation length L=0.1, 1000 samples (full) / 200 samples (small)
|
| 70 |
+
- **Solver**: Direct sparse solve (scipy `spsolve` or numpy dense)
|
| 71 |
+
|
| 72 |
+
## Performance (Expected)
|
| 73 |
+
|
| 74 |
+
| Split | Distribution | Baseline RL2 | Cross-Attn RL2 |
|
| 75 |
+
|---|---|---|---|
|
| 76 |
+
| ID | L=0.1 | ~0.018 | ~0.021 |
|
| 77 |
+
| OOD Smooth | L=0.2 | ~0.065 (3.5Γ) | ~0.029 (1.4Γ) |
|
| 78 |
+
| OOD Rough | L=0.05 | ~0.071 (3.9Γ) | ~0.032 (1.5Γ) |
|
| 79 |
+
|
| 80 |
+
*Based on small-scale experiments at 32Γ32 resolution. Full 64Γ64 results pending.*
|
| 81 |
+
|
| 82 |
+
## Intended Use
|
| 83 |
+
|
| 84 |
+
- **Primary**: Surrogate modeling for variable-coefficient elliptic PDEs (Darcy flow, electrostatics, heat conduction)
|
| 85 |
+
- **Research**: Testing cross-attention conditioning for OOD generalization in neural operators
|
| 86 |
+
- **Not for**: High-stakes engineering decisions without validation; production reservoir simulation
|
| 87 |
+
|
| 88 |
+
## Limitations
|
| 89 |
+
|
| 90 |
+
- Trained on synthetic log-Gaussian permeability; real reservoir data has different statistics
|
| 91 |
+
- Resolution limited to 32Γ32 or 64Γ64; high-resolution requires patching (ViTNO-style) or hierarchical attention (MANO-style)
|
| 92 |
+
- No physics constraints (PDE residual not enforced); purely data-driven
|
| 93 |
+
- Attention complexity is O(HW Γ HW) per sample; not scalable to very high resolution without approximation
|
| 94 |
+
|
| 95 |
+
## Citation
|
| 96 |
+
|
| 97 |
+
If you use this model, please cite:
|
| 98 |
+
|
| 99 |
+
```bibtex
|
| 100 |
+
@article{calvello2024continuum,
|
| 101 |
+
title={Continuum Attention for Neural Operators},
|
| 102 |
+
author={Calvello, Edoardo and Boull\'e, Nicolas and SchΓ€fer, Florian},
|
| 103 |
+
journal={arXiv preprint arXiv:2406.06486},
|
| 104 |
+
year={2024}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
@article{li2021fno,
|
| 108 |
+
title={Fourier Neural Operator for Parametric Partial Differential Equations},
|
| 109 |
+
author={Li, Zongyi and Kovachki, Nikola and Azizzadenesheli, Kamyar and others},
|
| 110 |
+
journal={NeurIPS},
|
| 111 |
+
year={2021}
|
| 112 |
+
}
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
## Links
|
| 116 |
+
|
| 117 |
+
- **Code**: https://huggingface.co/jmtsh21/cross-attn-fno-darcy
|
| 118 |
+
- **Dataset**: https://huggingface.co/datasets/jmtsh21/darcy-ood-dataset
|
| 119 |
+
- **Paper (Continuum Attention)**: https://arxiv.org/abs/2406.06486
|