Skip to content

Commit ed16bb4

Browse files
committed
feat(ppsci): support data_effient_nopt for inference
1 parent 1f404a2 commit ed16bb4

File tree

3 files changed

+102
-18
lines changed

3 files changed

+102
-18
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Usage
2+
3+
## 1. Data Download
4+
5+
数据来源参考如下。
6+
7+
|dataset| model | size| link |
8+
|---|---|---|---|
9+
|possion_64|Poisson (FNO)|6.2GB|https://drive.google.com/drive/folders/1crIsTZGxZULWhrXkwGDiWF33W6RHxJkf|
10+
|helmholtz_64|Helmholtz (FNO)|5.8GB|https://drive.google.com/drive/folders/1UjIaF6FsjmN_xlGGSUX-1K2V3EF2Zalw|
11+
12+
## 2. Pretraining
13+
14+
修改`config/operators_possion.yaml``config/operators_helmholtz.yaml`相关文件夹路径。
15+
16+
修改`run_pretrain.sh`中config路径,采用`possion_64``helmholtz_64`配置,同时指定`--config`预训练配置。
17+
18+
```shell
19+
bash run_pretrain.py
20+
```
21+
22+
## 3. Fine-tuning
23+
24+
修改`config/operators_possion.yaml``config/operators_helmholtz.yaml`相关文件夹路径。
25+
26+
修改`run_pretrain.sh`中config路径,采用`possion_64``helmholtz_64`配置,同时指定`--config`微调配置。
27+
28+
```shell
29+
bash run_pretrain.py
30+
```
31+
32+
## 4. In-context Learning
33+
34+
修改`config/inference_poisson.yaml``config/inference_helmholtz.yaml`相关文件夹路径。
35+
36+
修改`run_pretrain.sh`中config路径,采用`possion_64``helmholtz_64`配置,同时指定`--ckpt`权重路径。
37+
38+
```shell
39+
bash run_inference_possion.py
40+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
default:
2+
train_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o15_20_train.h5'
3+
test_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o15_20_test.h5'
4+
# scales_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o15_20_train_scale.npy'
5+
# datapath: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o16_test.h5'
6+
# datapath: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o15_test.h5'
7+
# datapath: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o16_tensor15_test.h5'
8+
# datapath: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_test.h5'
9+
scales_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_train_scale.npy'
10+
11+
num_data_workers: 1
12+
subsample: 1
13+
# num_demos: 0
14+
shuffle: False
15+
nx: 64
16+
nt: 64
17+
Lx: !!float 1.0
18+
Ly: !!float 1.0
19+
pack_data: !!bool False
20+
21+
model: 'fno'
22+
layers: [64, 64, 64, 64, 64]
23+
modes1: [65, 65, 65, 65]
24+
modes2: [65, 65, 65, 65]
25+
fc_dim: 128
26+
27+
in_dim: 3
28+
out_dim: 1
29+
mode_cut: 32
30+
embed_cut: 64
31+
fc_cut: 2
32+
dropout: 0
33+
34+
fix_backbone: True
35+
36+
loss_func: mse
37+
38+
batch_size: 1
39+
loss_style: sum
40+
41+
log_to_wandb: !!bool False
42+
logdir: ./log

examples/data_efficient_nopt/config/operators_helmholtz.yaml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ default: &DEFAULT
1414
# optimization
1515
optimizer: 'adam'
1616
scheduler: 'none'
17+
loss_style: 'mean'
18+
loss_func: 'mse'
1719
learning_rate: !!float 1.0
1820
max_epochs: 500
1921
scheduler_epochs: 500
2022
weight_decay: 0
2123
batch_size: 25
2224
# misc
23-
log_to_screen: !!bool False
25+
log_to_screen: !!bool True
2426
save_checkpoint: !!bool False
2527
seed: 0
2628
plot_figs: !!bool False
@@ -43,7 +45,7 @@ default: &DEFAULT
4345
accum_grad: 1
4446
enable_amp: !!bool False
4547
log_interval: 1
46-
checkpoint_save_interval: 10
48+
checkpoint_save_interval: 250
4749
debug_grad: False
4850

4951
helmholtz: &helmholtz
@@ -52,7 +54,7 @@ helmholtz: &helmholtz
5254
batch_size: 128
5355
nx: 128
5456
ny: 128
55-
log_to_wandb: !!bool True
57+
log_to_wandb: !!bool False
5658
save_checkpoint: !!bool True
5759
max_epochs: 500
5860
scheduler: 'cosine'
@@ -76,11 +78,11 @@ helmholtz: &helmholtz
7678

7779
helm-64-scale-o5_15: &helm_64_o5_15
7880
<<: *helmholtz
79-
train_path: '/path/to/helmholtz_64_o5_15_train.h5'
80-
val_path: '/path/to/helmholtz_64_o5_15_val.h5'
81-
test_path: '/path/to/helmholtz_64_o5_15_test.h5'
82-
scales_path: '/path/to/helmholtz_64_o5_15_train_scale.npy'
83-
# train_rand_idx_path: '/path/to/old_gen/train_rand_idx.npy'
81+
train_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_train.h5'
82+
val_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_val.h5'
83+
test_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_test.h5'
84+
scales_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_train_scale.npy'
85+
# train_rand_idx_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/old_gen/train_rand_idx.npy'
8486
batch_size: 128
8587
in_dim: 3
8688
out_dim: 1
@@ -99,11 +101,11 @@ helm-64-scale-o5_15: &helm_64_o5_15
99101

100102
helm-64-pretrain-o1_20: &helm_64_o1_20_pt
101103
<<: *helmholtz
102-
train_path: '/path/to/helmholtz_64_o1_20_train.h5'
103-
val_path: '/path/to/helmholtz_64_o1_20_val.h5'
104-
test_path: '/path/to/helmholtz_64_o1_20_test.h5'
105-
scales_path: '/path/to/helmholtz_64_o1_20_train_scale.npy'
106-
train_rand_idx_path: '/path/to/train_rand_idx.npy'
104+
train_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o1_20_train.h5'
105+
val_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o1_20_val.h5'
106+
test_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o1_20_test.h5'
107+
scales_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o1_20_train_scale.npy'
108+
train_rand_idx_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/train_rand_idx.npy'
107109
batch_size: 128
108110
in_dim: 3
109111
out_dim: 1
@@ -126,11 +128,11 @@ helm-64-pretrain-o1_20_ft: &helm_64_o1_20_ft
126128

127129
helm-64-finetune-o5_15: &helm_64_o5_15_ft
128130
<<: *helmholtz
129-
train_path: '/path/to/helmholtz_64_o5_15_train.h5'
130-
val_path: '/path/to/helmholtz_64_o5_15_val.h5'
131-
test_path: '/path/to/helmholtz_64_o5_15_test.h5'
132-
scales_path: '/path/to/helmholtz_64_o5_15_train_scale.npy'
133-
train_rand_idx_path: '/path/to/train_rand_idx.npy'
131+
train_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_train.h5'
132+
val_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_val.h5'
133+
test_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_test.h5'
134+
scales_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/helmholtz_64_o5_15_train_scale.npy'
135+
train_rand_idx_path: '/home/aistudio/data_efficient_nopt/data/helmholtz_64/helmholtz_64/train_rand_idx.npy'
134136
batch_size: 128
135137
in_dim: 3 #normal helmholtz has 3 dim, joint has 4
136138
out_dim: 1

0 commit comments

Comments
 (0)