Add paper link, GitHub repository, and metadata

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +32 -270
README.md CHANGED
@@ -1,3 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # PDEInvBench Data Guide
2
  Data guide for the dataset accompanying PDEInvBench.
3
  <img src="images/pde_objectives_main_fig_1.png" alt="" width="400">
@@ -25,15 +55,13 @@ Data guide for the dataset accompanying PDEInvBench.
25
 
26
  The dataset used in this project can be found here:
27
  https://huggingface.co/datasets/DabbyOWL/PDE_Inverse_Problem_Benchmarking/tree/main
 
28
  ## 2. Downloading Data
29
  We provide a python script: [`huggingface_pdeinv_download.py`](huggingface_pdeinv_download.py) to batch download our hugging-face data. We will update the readme of our hugging-face dataset and our github repo to reflect this addition. To run this:
30
  ```bash
31
  pip install huggingface_hub
32
  python3 huggingface_pdeinv_download.py [--dataset DATASET_NAME] [--split SPLIT] [--local-dir PATH]
33
  ```
34
- **Available datasets:** `darcy-flow-241`, `darcy-flow-421`, `korteweg-de-vries-1d`, `navier-stokes-forced-2d-2048`, `navier-stokes-forced-2d`, `navier-stokes-unforced-2d`, `reaction-diffusion-2d-du-512`, `reaction-diffusion-2d-du`, `reaction-diffusion-2d-k-512`, `reaction-diffusion-2d-k`
35
- **Available splits:** `*` (all), `train`, `validation`, `test`, `out_of_distribution`, `out_of_distribution_extreme`
36
-
37
 
38
  ## 3. Overview
39
 
@@ -511,270 +539,4 @@ Contents:
511
  - `sol`: Solution field
512
 
513
  ## 5. Adding a New Dataset
514
- The PDEInvBench framework is designed to be modular, allowing you to add new PDE systems. This section describes how to add a new dataset to the repository. For information about data format requirements, see [Section 4.1](#41-data-format).
515
- ### Table of Contents
516
- - [Step 1: Add PDE Type to Utils](#step-1-add-pde-type-to-utils)
517
- - [Step 2: Add PDE Attributes](#step-2-add-pde-attributes)
518
- - [Step 3: Add Parameter Normalization Stats](#step-3-add-parameter-normalization-stats)
519
- - [Step 4: Add Parameter Extraction Logic](#step-4-add-parameter-extraction-logic)
520
- - [Step 5: Create a Dataset Handler](#step-5-create-a-dataset-handler-if-needed)
521
- - [Step 6: Create a Data Configuration](#step-6-create-a-data-configuration)
522
- - [Step 7: Add Residual Functions](#step-7-add-residual-functions)
523
- - [Step 8: Create a Combined Configuration](#step-8-create-a-combined-configuration)
524
- - [Step 9: Generate and Prepare Data](#step-9-generate-and-prepare-data)
525
- - [Step 10: Run Experiments](#step-10-run-experiments)
526
- - [Data Format Requirements](#data-format-requirements)
527
- ### Step 1: Add PDE Type to Utils
528
- First, add your new PDE system to `pdeinvbench/utils/types.py`:
529
- ```python
530
- class PDE(enum.Enum):
531
- """
532
- Describes which PDE system currently being used.
533
- """
534
- # Existing PDEs...
535
- ReactionDiffusion1D = "Reaction Diffusion 1D"
536
- ReactionDiffusion2D = "Reaction Diffusion 2D"
537
- NavierStokes2D = "Navier Stokes 2D"
538
- # Add your new PDE
539
- YourNewPDE = "Your New PDE Description"
540
- ```
541
- ### Step 2: Add PDE Attributes
542
- Update the attribute dictionaries in `pdeinvbench/utils/types.py` with information about your new PDE:
543
- ```python
544
- # Number of partial derivatives
545
- PDE_PARTIALS = {
546
- # Existing PDEs...
547
- PDE.YourNewPDE: 3, # Number of partial derivatives needed
548
- }
549
- # Number of spatial dimensions
550
- PDE_NUM_SPATIAL = {
551
- # Existing PDEs...
552
- PDE.YourNewPDE: 2, # 1 for 1D PDEs, 2 for 2D PDEs
553
- }
554
- # Spatial size of the grid
555
- PDE_SPATIAL_SIZE = {
556
- # Existing PDEs...
557
- PDE.YourNewPDE: [128, 128], # Spatial dimensions of your dataset
558
- }
559
- # High-resolution spatial size (if applicable)
560
- HIGH_RESOLUTION_PDE_SPATIAL_SIZE = {
561
- # Existing PDEs...
562
- PDE.YourNewPDE: [512, 512], # High-res dimensions
563
- }
564
- # Number of parameters
565
- PDE_NUM_PARAMETERS = {
566
- # Existing PDEs...
567
- PDE.YourNewPDE: 2, # Number of parameters in your PDE
568
- }
569
- # Parameter values
570
- PDE_PARAM_VALUES = {
571
- # Existing PDEs...
572
- PDE.YourNewPDE: {
573
- "param1": [0.1, 0.2, 0.3], # List of possible values for param1
574
- "param2": [1.0, 2.0, 3.0], # List of possible values for param2
575
- },
576
- }
577
- # Number of data channels
578
- PDE_NUM_CHANNELS = {
579
- # Existing PDEs...
580
- PDE.YourNewPDE: 2, # Number of channels in your solution field
581
- }
582
- # Number of timesteps in the trajectory
583
- PDE_TRAJ_LEN = {
584
- # Existing PDEs...
585
- PDE.YourNewPDE: 100, # Number of timesteps in your trajectories
586
- }
587
- ```
588
- ### Step 3: Add Parameter Normalization Stats
589
-
590
- Update `pdeinvbench/data/utils.py` with normalization statistics for your PDE parameters:
591
-
592
- ```python
593
- PARAM_NORMALIZATION_STATS = {
594
- # Existing PDEs...
595
- PDE.YourNewPDE: {
596
- "param1": (0.2, 0.05), # (mean, std) for param1
597
- "param2": (2.0, 0.5), # (mean, std) for param2
598
- },
599
- }
600
- ```
601
-
602
- ### Step 4: Add Parameter Extraction Logic
603
-
604
- Add logic to extract parameters from your dataset files in `extract_params_from_path` function inside the dataset class:
605
-
606
- ```python
607
- def extract_params_from_path(path: str, pde: PDE) -> dict:
608
- # Existing code...
609
- elif pde == PDE.YourNewPDE:
610
- # Parse the filename to extract parameters
611
- name = os.path.basename(path)
612
- # Example: extract parameters from filename format "param1=X_param2=Y.h5"
613
- param1 = torch.Tensor([float(name.split("param1=")[1].split("_")[0])])
614
- param2 = torch.Tensor([float(name.split("param2=")[1].split(".")[0])])
615
- param_dict = {"param1": param1, "param2": param2}
616
- # Existing code...
617
- return param_dict
618
- ```
619
-
620
- ### Step 5: Create a Dataset Handler (if needed)
621
-
622
- If your PDE requires special handling beyond what `PDE_MultiParam` provides, create a new dataset class in `pdeinvbench/data/`:
623
-
624
- ```python
625
- # Example: pdeinvbench/data/your_new_pde_dataset.py
626
- import torch
627
- from torch.utils.data import Dataset
628
- class YourNewPDEDataset(Dataset):
629
- """
630
- Custom dataset class for your new PDE system.
631
- """
632
- def __init__(
633
- self,
634
- data_root: str,
635
- pde: PDE,
636
- n_past: int,
637
- n_future: int,
638
- mode: str,
639
- train: bool,
640
- # Other parameters...
641
- ):
642
- # Initialization code...
643
- pass
644
-
645
- def __len__(self):
646
- # Implementation...
647
- pass
648
-
649
- def __getitem__(self, index: int):
650
- # Implementation...
651
- pass
652
- ```
653
-
654
- Add your new dataset to `pdeinvbench/data/__init__.py`:
655
-
656
- ```python
657
- from .pde_multiparam import PDE_MultiParam
658
- from .your_new_pde_dataset import YourNewPDEDataset
659
- __all__ = ["PDE_MultiParam", "YourNewPDEDataset"]
660
- ```
661
-
662
- ```markdown
663
- ### Step 6: Create System Configuration
664
- Create `configs/system_params/your_new_pde.yaml`:
665
- ```yaml
666
- # configs/system_params/your_new_pde.yaml
667
- defaults:
668
- - base
669
- # ============ Data Parameters ============
670
- name: "your_new_pde_inverse"
671
- data_root: "/path/to/your/data"
672
- pde_name: "Your New PDE Description" # Must match PDE enum value
673
- num_channels: 2 # Number of solution channels (e.g., u and v)
674
- cutoff_first_n_frames: 0 # How many initial frames to skip
675
-
676
- # ============ Model Parameters ============
677
- downsampler_input_dim: 2 # 1 for 1D systems, 2 for 2D systems
678
- params_to_predict: ["param1", "param2"] # What parameters to predict
679
- normalize: True # Whether to normalize predicted parameters
680
- ```
681
- Then create the top-level config `configs/your_new_pde.yaml`:
682
- ```yaml
683
- # configs/your_new_pde.yaml
684
- name: your_new_pde
685
- defaults:
686
- - _self_
687
- - base
688
- - override system_params: your_new_pde
689
- ```
690
- The existing configs/data/base.yaml automatically references ${system_params.*} so data loading works out of the box. Run experiments with:
691
- ```yaml
692
- python train_inverse.py --config-name=your_new_pde
693
- python train_inverse.py --config-name=your_new_pde model=fno
694
- python train_inverse.py --config-name=your_new_pde model=resnet
695
- ```
696
- ### Step 7: Add Residual Functions
697
- Implement residual functions for your PDE in `pdeinvbench/losses/pde_residuals.py`:
698
- ```python
699
- def your_new_pde_residual(
700
- sol: torch.Tensor,
701
- params: Dict[str, torch.Tensor],
702
- spatial_grid: Tuple[torch.Tensor, ...],
703
- t: torch.Tensor,
704
- return_partials: bool = False,
705
- ) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
706
- """
707
- Compute the residual for your new PDE.
708
-
709
- Args:
710
- sol: Solution field
711
- params: Dictionary of PDE parameters
712
- spatial_grid: Spatial grid coordinates
713
- t: Time coordinates
714
- return_partials: Whether to return partial derivatives
715
-
716
- Returns:
717
- Residual tensor or (residual, partials) if return_partials=True
718
- """
719
- # Implementation...
720
- pass
721
- ```
722
- Register your residual function in `get_pde_residual_function`:
723
- ```python
724
- def get_pde_residual_function(pde: PDE) -> Callable:
725
- """Return the appropriate residual function for the given PDE."""
726
- if pde == PDE.ReactionDiffusion2D:
727
- return reaction_diffusion_2d_residual
728
- # Add your PDE
729
- elif pde == PDE.YourNewPDE:
730
- return your_new_pde_residual
731
- # Other PDEs...
732
- else:
733
- raise ValueError(f"Unknown PDE type: {pde}")
734
- ```
735
- ### Step 8: Create a Combined Configuration
736
- Create a combined configuration that uses your dataset:
737
- ```yaml
738
- # configs/your_new_pde.yaml
739
- name: "your_new_pde"
740
- defaults:
741
- - _self_
742
- - base
743
- - override data: your_new_pde
744
- ```
745
- ### Step 9: Generate and Prepare Data
746
- Make sure your data is properly formatted and stored in the expected directory structure:
747
- ```
748
- /path/to/your/data/
749
- ├── train/
750
- │ ├── param1=0.1_param2=1.0.h5
751
- │ ├── param1=0.2_param2=2.0.h5
752
- │ └── ...
753
- ├── validation/
754
- │ ├── param1=0.15_param2=1.5.h5
755
- │ └── ...
756
- └── test/
757
- ├── param1=0.25_param2=2.5.h5
758
- └── ...
759
- ```
760
- Each HDF5 file should contain:
761
- - Solution trajectories
762
- - Grid information (x, y, t)
763
- - Any other metadata needed for your PDE
764
- ### Step 10: Run Experiments
765
- You can now run experiments with your new dataset:
766
- ```bash
767
- python train_inverse.py --config-name=your_new_pde
768
- ```
769
- ### Data Format Requirements
770
- The primary dataset class `PDE_MultiParam` expects data in HDF5 format with specific structure:
771
- - **1D PDEs**: Each HDF5 file contains a single trajectory with keys:
772
- - `tensor`: The solution field with shape `[time, spatial_dim]`
773
- - `x-coordinate`: Spatial grid points
774
- - `t-coordinate`: Time points
775
- - **2D PDEs**: Each HDF5 file contains multiple trajectories (one per IC):
776
- - `0001/data`: Solution field with shape `[time, spatial_dim_1, spatial_dim_2, channels]`
777
- - `0001/grid/x`: x-coordinates
778
- - `0001/grid/y`: y-coordinates
779
- - `0001/grid/t`: Time points
780
- - **File naming**: The filename should encode the PDE parameters, following the format expected by `extract_params_from_path`
 
1
+ ---
2
+ task_categories:
3
+ - other
4
+ tags:
5
+ - physics
6
+ - scientific-computing
7
+ - pde
8
+ - inverse-problems
9
+ ---
10
+
11
+ # PDEInvBench: A Comprehensive Dataset and Design Space Exploration of Neural Networks for PDE Inverse Problems
12
+
13
+ This is the official dataset for the paper [PDEInvBench: A Comprehensive Dataset and Design Space Exploration of Neural Networks for PDE Inverse Problems](https://huggingface.co/papers/2605.25353).
14
+
15
+ **Code**: [GitHub - ASK-Berkeley/PDEInvBench](https://github.com/ASK-Berkeley/PDEInvBench)
16
+
17
+ ## Sample Usage
18
+
19
+ You can use the provided script from the codebase to batch download the data:
20
+
21
+ ```bash
22
+ pip install huggingface_hub
23
+ python3 huggingface_pdeinv_download.py --dataset darcy-flow-241 --split train --local-dir ./data
24
+ ```
25
+
26
+ **Available datasets:** `darcy-flow-241`, `darcy-flow-421`, `korteweg-de-vries-1d`, `navier-stokes-forced-2d-2048`, `navier-stokes-forced-2d`, `navier-stokes-unforced-2d`, `reaction-diffusion-2d-du-512`, `reaction-diffusion-2d-du`, `reaction-diffusion-2d-k-512`, `reaction-diffusion-2d-k`
27
+ **Available splits:** `*` (all), `train`, `validation`, `test`, `out_of_distribution`, `out_of_distribution_extreme`
28
+
29
+ ---
30
+
31
  # PDEInvBench Data Guide
32
  Data guide for the dataset accompanying PDEInvBench.
33
  <img src="images/pde_objectives_main_fig_1.png" alt="" width="400">
 
55
 
56
  The dataset used in this project can be found here:
57
  https://huggingface.co/datasets/DabbyOWL/PDE_Inverse_Problem_Benchmarking/tree/main
58
+
59
  ## 2. Downloading Data
60
  We provide a python script: [`huggingface_pdeinv_download.py`](huggingface_pdeinv_download.py) to batch download our hugging-face data. We will update the readme of our hugging-face dataset and our github repo to reflect this addition. To run this:
61
  ```bash
62
  pip install huggingface_hub
63
  python3 huggingface_pdeinv_download.py [--dataset DATASET_NAME] [--split SPLIT] [--local-dir PATH]
64
  ```
 
 
 
65
 
66
  ## 3. Overview
67
 
 
539
  - `sol`: Solution field
540
 
541
  ## 5. Adding a New Dataset
542
+ The PDEInvBench framework is designed to be modular, allowing you to add new PDE systems. This section describes how to add a new dataset to the repository. For information about data format requirements, see [Section 4.1](#41-data-format).