mamoeed commited on
Commit
2b0cbd3
·
verified ·
1 Parent(s): 7292133

Upload generate_datasets.ipynb

Browse files
Files changed (1) hide show
  1. generate_datasets.ipynb +781 -0
generate_datasets.ipynb ADDED
@@ -0,0 +1,781 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "d865b0fe-d47f-424c-9f19-51647414f06f",
6
+ "metadata": {},
7
+ "source": [
8
+ "### Notebook for generating datasets \n",
9
+ "\n",
10
+ "Create datasets using apebench (jax) to be used by torch models for trainings.\n",
11
+ "Agree on a fixed naming convention."
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": 1,
17
+ "id": "472f2bd0-64b3-44f8-b930-03e64a776144",
18
+ "metadata": {},
19
+ "outputs": [
20
+ {
21
+ "name": "stderr",
22
+ "output_type": "stream",
23
+ "text": [
24
+ "/home/moeed/miniconda3/envs/apebench/lib/python3.12/site-packages/trainax/_general_trainer.py:7: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
25
+ " from tqdm.autonotebook import tqdm\n"
26
+ ]
27
+ }
28
+ ],
29
+ "source": [
30
+ "import apebench\n",
31
+ "import numpy as np\n",
32
+ "import jax.numpy as jnp\n",
33
+ "import seaborn as sns\n",
34
+ "from scipy import stats\n",
35
+ "import matplotlib.pyplot as plt"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 12,
41
+ "id": "2197b3c3-093d-46cc-92f1-fd0d5b144b68",
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "# data generation configs\n",
46
+ "spatial_grid_points = 128\n",
47
+ "spatial_dims = 2\n",
48
+ "num_train_samples = 100\n",
49
+ "train_time_steps = 50\n",
50
+ "num_test_samples = 40\n",
51
+ "test_time_steps = 200\n"
52
+ ]
53
+ },
54
+ {
55
+ "cell_type": "markdown",
56
+ "id": "e95ac47f-49ef-4c9e-aaf4-26744007d4ba",
57
+ "metadata": {},
58
+ "source": [
59
+ "Data from advection scenario"
60
+ ]
61
+ },
62
+ {
63
+ "cell_type": "markdown",
64
+ "id": "1aaa1495-dc7e-4a32-b046-65f8ec1d62dc",
65
+ "metadata": {},
66
+ "source": [
67
+ "Advection hard for 2D"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "execution_count": 13,
73
+ "id": "d7aef0d2-f151-4ef1-a591-829acfb6d246",
74
+ "metadata": {},
75
+ "outputs": [],
76
+ "source": [
77
+ "# more difficult advection equation\n",
78
+ "advection2D_hard_scenario = apebench.scenarios.difficulty.Advection(\n",
79
+ " \n",
80
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
81
+ "\n",
82
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
83
+ " \n",
84
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
85
+ "\n",
86
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
87
+ " \n",
88
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
89
+ " \n",
90
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
91
+ "\n",
92
+ " train_seed = 0,\n",
93
+ "\n",
94
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
95
+ " \n",
96
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
97
+ "\n",
98
+ " test_seed = 773,\n",
99
+ " \n",
100
+ " advection_gamma=-10.5,\n",
101
+ ")"
102
+ ]
103
+ },
104
+ {
105
+ "cell_type": "code",
106
+ "execution_count": 14,
107
+ "id": "92855a20-0981-4d91-be73-86b95b83cdf5",
108
+ "metadata": {},
109
+ "outputs": [
110
+ {
111
+ "name": "stdout",
112
+ "output_type": "stream",
113
+ "text": [
114
+ "train data shape (100, 51, 1, 128, 128)\n",
115
+ "test ICs shape (40, 1, 128, 128)\n",
116
+ "complete test data shape (40, 201, 1, 128, 128)\n",
117
+ "val data (10, 51, 1, 128, 128)\n",
118
+ "test data after removing val (30, 201, 1, 128, 128)\n"
119
+ ]
120
+ }
121
+ ],
122
+ "source": [
123
+ "train_data = advection2D_hard_scenario.get_train_data()\n",
124
+ "print('train data shape',train_data.shape)\n",
125
+ "\n",
126
+ "test_ic_set = advection2D_hard_scenario.get_test_ic_set()\n",
127
+ "print('test ICs shape',test_ic_set.shape)\n",
128
+ "\n",
129
+ "full_test_data = advection2D_hard_scenario.get_test_data() \n",
130
+ "print('complete test data shape',full_test_data.shape)\n",
131
+ "\n",
132
+ "val_data = full_test_data[:10,:51,:,:]\n",
133
+ "print('val data',val_data.shape)\n",
134
+ "\n",
135
+ "test_data = full_test_data[10:,:,:,:]\n",
136
+ "print('test data after removing val',test_data.shape)"
137
+ ]
138
+ },
139
+ {
140
+ "cell_type": "code",
141
+ "execution_count": 15,
142
+ "id": "b5bf0add-1b5d-48fe-8463-5477d7fda33a",
143
+ "metadata": {},
144
+ "outputs": [],
145
+ "source": [
146
+ "# jnp.save(\"advection2D_hard_train_data_128x128_100ic_50t.npy\", train_data)\n",
147
+ "# jnp.save(\"advection2D_hard_val_data_128x128_10ic_50t.npy\", val_data)\n",
148
+ "# jnp.save(\"advection2D_hard_test_data_128x128_30ic_200t.npy\", test_data)\n"
149
+ ]
150
+ },
151
+ {
152
+ "cell_type": "markdown",
153
+ "id": "3562aa84-7db2-4e94-bfb6-0bd99b83db67",
154
+ "metadata": {},
155
+ "source": [
156
+ "Data from kuramoto sivashinksy scenario"
157
+ ]
158
+ },
159
+ {
160
+ "cell_type": "code",
161
+ "execution_count": 16,
162
+ "id": "86b4595a-1371-4f6f-8faa-7bfe2d649276",
163
+ "metadata": {},
164
+ "outputs": [],
165
+ "source": [
166
+ "kuramoto2D_scenario = apebench.scenarios.difficulty.KuramotoSivashinsky(\n",
167
+ " \n",
168
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
169
+ " \n",
170
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
171
+ " \n",
172
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
173
+ "\n",
174
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
175
+ " \n",
176
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
177
+ " \n",
178
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
179
+ "\n",
180
+ " train_seed = 0,\n",
181
+ "\n",
182
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
183
+ " \n",
184
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
185
+ "\n",
186
+ " test_seed = 773,\n",
187
+ ")"
188
+ ]
189
+ },
190
+ {
191
+ "cell_type": "code",
192
+ "execution_count": 17,
193
+ "id": "dccb6e26-4835-4d76-ab38-c06995cf7e51",
194
+ "metadata": {},
195
+ "outputs": [
196
+ {
197
+ "name": "stdout",
198
+ "output_type": "stream",
199
+ "text": [
200
+ "train data shape (100, 51, 1, 128, 128)\n",
201
+ "test ICs shape (40, 1, 128, 128)\n",
202
+ "complete test data shape (40, 201, 1, 128, 128)\n",
203
+ "val data (10, 51, 1, 128, 128)\n",
204
+ "test data after removing val (30, 201, 1, 128, 128)\n"
205
+ ]
206
+ }
207
+ ],
208
+ "source": [
209
+ "# data from kuramoto scenario \n",
210
+ "train_data = kuramoto2D_scenario.get_train_data()\n",
211
+ "print('train data shape',train_data.shape)\n",
212
+ "\n",
213
+ "test_ic_set = kuramoto2D_scenario.get_test_ic_set()\n",
214
+ "print('test ICs shape',test_ic_set.shape)\n",
215
+ "\n",
216
+ "full_test_data = kuramoto2D_scenario.get_test_data() \n",
217
+ "print('complete test data shape',full_test_data.shape)\n",
218
+ "\n",
219
+ "val_data = full_test_data[:10,:51,:,:]\n",
220
+ "print('val data',val_data.shape)\n",
221
+ "\n",
222
+ "test_data = full_test_data[10:,:,:,:]\n",
223
+ "print('test data after removing val',test_data.shape)\n"
224
+ ]
225
+ },
226
+ {
227
+ "cell_type": "code",
228
+ "execution_count": 19,
229
+ "id": "0233bd94-e51d-4b89-89ad-0f83ccaec2ef",
230
+ "metadata": {},
231
+ "outputs": [],
232
+ "source": [
233
+ "# jnp.save(\"kuramoto2D_train_data_128x128_100ic_50t.npy\", train_data)\n",
234
+ "# jnp.save(\"kuramoto2D_val_data_128x128_10ic_50t.npy\", val_data)\n",
235
+ "# jnp.save(\"kuramoto2D_test_data_128x128_30ic_200t.npy\", test_data)\n"
236
+ ]
237
+ },
238
+ {
239
+ "cell_type": "markdown",
240
+ "id": "1e51cde4-241b-4c79-8c11-791e375687b4",
241
+ "metadata": {},
242
+ "source": [
243
+ "Data from advection diffusion scenario"
244
+ ]
245
+ },
246
+ {
247
+ "cell_type": "code",
248
+ "execution_count": 20,
249
+ "id": "bb39fe39-e208-4fa8-8688-53035c9aecfa",
250
+ "metadata": {},
251
+ "outputs": [],
252
+ "source": [
253
+ "advdiff2D_scenario = apebench.scenarios.difficulty.AdvectionDiffusion(\n",
254
+ " \n",
255
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
256
+ "\n",
257
+ " \n",
258
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
259
+ " \n",
260
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
261
+ "\n",
262
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
263
+ " \n",
264
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
265
+ " \n",
266
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
267
+ "\n",
268
+ " train_seed = 0,\n",
269
+ "\n",
270
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
271
+ " \n",
272
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
273
+ "\n",
274
+ " test_seed = 773,\n",
275
+ ")"
276
+ ]
277
+ },
278
+ {
279
+ "cell_type": "code",
280
+ "execution_count": 22,
281
+ "id": "ac69e48e-7bba-45a7-89f8-1add76e87a8f",
282
+ "metadata": {},
283
+ "outputs": [
284
+ {
285
+ "name": "stdout",
286
+ "output_type": "stream",
287
+ "text": [
288
+ "train data shape (100, 51, 1, 128, 128)\n",
289
+ "test ICs shape (40, 1, 128, 128)\n",
290
+ "complete test data shape (40, 201, 1, 128, 128)\n",
291
+ "val data (10, 51, 1, 128, 128)\n",
292
+ "test data after removing val (30, 201, 1, 128, 128)\n"
293
+ ]
294
+ }
295
+ ],
296
+ "source": [
297
+ "# data from advection diffusion\n",
298
+ "train_data = advdiff2D_scenario.get_train_data()\n",
299
+ "print('train data shape',train_data.shape)\n",
300
+ "\n",
301
+ "test_ic_set = advdiff2D_scenario.get_test_ic_set()\n",
302
+ "print('test ICs shape',test_ic_set.shape)\n",
303
+ "\n",
304
+ "full_test_data = advdiff2D_scenario.get_test_data() \n",
305
+ "print('complete test data shape',full_test_data.shape)\n",
306
+ "\n",
307
+ "val_data = full_test_data[:10,:51,:,:]\n",
308
+ "print('val data',val_data.shape)\n",
309
+ "\n",
310
+ "test_data = full_test_data[10:,:,:,:]\n",
311
+ "print('test data after removing val',test_data.shape)\n",
312
+ "\n"
313
+ ]
314
+ },
315
+ {
316
+ "cell_type": "code",
317
+ "execution_count": 25,
318
+ "id": "98b2ad28-243f-4a87-ac30-7d7fc0873fd9",
319
+ "metadata": {},
320
+ "outputs": [],
321
+ "source": [
322
+ "# jnp.save(\"advdiff2D_train_data_128x128_100ic_50t.npy\", train_data)\n",
323
+ "# jnp.save(\"advdiff2D_val_data_128x128_10ic_50t.npy\", val_data)\n",
324
+ "# jnp.save(\"advdiff2D_test_data_128x128_30ic_200t.npy\", test_data)\n"
325
+ ]
326
+ },
327
+ {
328
+ "cell_type": "code",
329
+ "execution_count": 24,
330
+ "id": "55fb63eb-9155-4817-b0d2-cb2dd0b33878",
331
+ "metadata": {},
332
+ "outputs": [],
333
+ "source": [
334
+ "burgers2D_scenario = apebench.scenarios.difficulty.Burgers(\n",
335
+ " \n",
336
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
337
+ "\n",
338
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
339
+ " \n",
340
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
341
+ "\n",
342
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
343
+ " \n",
344
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
345
+ " \n",
346
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
347
+ "\n",
348
+ " train_seed = 0,\n",
349
+ "\n",
350
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
351
+ " \n",
352
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
353
+ "\n",
354
+ " test_seed = 773,\n",
355
+ " \n",
356
+ ")"
357
+ ]
358
+ },
359
+ {
360
+ "cell_type": "code",
361
+ "execution_count": 26,
362
+ "id": "f8654e86-250f-462b-8f8c-099e95855043",
363
+ "metadata": {},
364
+ "outputs": [
365
+ {
366
+ "name": "stdout",
367
+ "output_type": "stream",
368
+ "text": [
369
+ "train data shape (100, 51, 2, 128, 128)\n",
370
+ "test ICs shape (40, 2, 128, 128)\n",
371
+ "complete test data shape (40, 201, 2, 128, 128)\n",
372
+ "val data (10, 51, 2, 128, 128)\n",
373
+ "test data after removing val (30, 201, 2, 128, 128)\n"
374
+ ]
375
+ }
376
+ ],
377
+ "source": [
378
+ "# data from burgers\n",
379
+ "train_data = burgers2D_scenario.get_train_data()\n",
380
+ "print('train data shape',train_data.shape)\n",
381
+ "\n",
382
+ "test_ic_set = burgers2D_scenario.get_test_ic_set()\n",
383
+ "print('test ICs shape',test_ic_set.shape)\n",
384
+ "\n",
385
+ "full_test_data = burgers2D_scenario.get_test_data() \n",
386
+ "print('complete test data shape',full_test_data.shape)\n",
387
+ "\n",
388
+ "val_data = full_test_data[:10,:51,:,:]\n",
389
+ "print('val data',val_data.shape)\n",
390
+ "\n",
391
+ "test_data = full_test_data[10:,:,:,:]\n",
392
+ "print('test data after removing val',test_data.shape)\n",
393
+ "\n"
394
+ ]
395
+ },
396
+ {
397
+ "cell_type": "code",
398
+ "execution_count": 27,
399
+ "id": "19bc4cf4-af8b-4ad9-bb73-76f98b20e43e",
400
+ "metadata": {},
401
+ "outputs": [],
402
+ "source": [
403
+ "# jnp.save(\"burgers2D_train_data_128x128_100ic_50t.npy\", train_data)\n",
404
+ "# jnp.save(\"burgers2D_val_data_128x128_10ic_50t.npy\", val_data)\n",
405
+ "# jnp.save(\"burgers2D_test_data_128x128_30ic_200t.npy\", test_data)\n"
406
+ ]
407
+ },
408
+ {
409
+ "cell_type": "code",
410
+ "execution_count": null,
411
+ "id": "2e176902-3626-4634-9447-d65167de7688",
412
+ "metadata": {},
413
+ "outputs": [],
414
+ "source": []
415
+ },
416
+ {
417
+ "cell_type": "code",
418
+ "execution_count": 29,
419
+ "id": "e2b7d30d-4e16-4b9f-b544-d7e3e050a096",
420
+ "metadata": {},
421
+ "outputs": [],
422
+ "source": [
423
+ "fisher2D_scenario = apebench.scenarios.difficulty.FisherKPP(\n",
424
+ " \n",
425
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
426
+ "\n",
427
+ " \n",
428
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
429
+ " \n",
430
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
431
+ "\n",
432
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
433
+ " \n",
434
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
435
+ " \n",
436
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
437
+ "\n",
438
+ " train_seed = 0,\n",
439
+ "\n",
440
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
441
+ " \n",
442
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
443
+ "\n",
444
+ " test_seed = 773,\n",
445
+ ")"
446
+ ]
447
+ },
448
+ {
449
+ "cell_type": "code",
450
+ "execution_count": 30,
451
+ "id": "154d74a7-3fd1-45db-acee-f1508ee75f04",
452
+ "metadata": {},
453
+ "outputs": [
454
+ {
455
+ "name": "stdout",
456
+ "output_type": "stream",
457
+ "text": [
458
+ "train data shape (100, 51, 1, 128, 128)\n",
459
+ "test ICs shape (40, 1, 128, 128)\n",
460
+ "complete test data shape (40, 201, 1, 128, 128)\n",
461
+ "val data (10, 51, 1, 128, 128)\n",
462
+ "test data after removing val (30, 201, 1, 128, 128)\n"
463
+ ]
464
+ }
465
+ ],
466
+ "source": [
467
+ "# data from fisher-kpp\n",
468
+ "train_data = fisher2D_scenario.get_train_data()\n",
469
+ "print('train data shape',train_data.shape)\n",
470
+ "\n",
471
+ "test_ic_set = fisher2D_scenario.get_test_ic_set()\n",
472
+ "print('test ICs shape',test_ic_set.shape)\n",
473
+ "\n",
474
+ "full_test_data = fisher2D_scenario.get_test_data() \n",
475
+ "print('complete test data shape',full_test_data.shape)\n",
476
+ "\n",
477
+ "val_data = full_test_data[:10,:51,:,:]\n",
478
+ "print('val data',val_data.shape)\n",
479
+ "\n",
480
+ "test_data = full_test_data[10:,:,:,:]\n",
481
+ "print('test data after removing val',test_data.shape)\n",
482
+ "\n"
483
+ ]
484
+ },
485
+ {
486
+ "cell_type": "code",
487
+ "execution_count": 31,
488
+ "id": "9cd14e27-23ed-4e05-b63a-aa38df53a945",
489
+ "metadata": {},
490
+ "outputs": [],
491
+ "source": [
492
+ "# jnp.save(\"fisher2D_train_data_128x128_100ic_50t.npy\", train_data)\n",
493
+ "# jnp.save(\"fisher2D_val_data_128x128_10ic_50t.npy\", val_data)\n",
494
+ "# jnp.save(\"fisher2D_test_data_128x128_30ic_200t.npy\", test_data)\n"
495
+ ]
496
+ },
497
+ {
498
+ "cell_type": "markdown",
499
+ "id": "18d43b36-1c1e-4ec6-8bd1-532f08e334ff",
500
+ "metadata": {},
501
+ "source": [
502
+ "2D Kolmogorov flow. Kolmogorov forcing of Navier stokes:"
503
+ ]
504
+ },
505
+ {
506
+ "cell_type": "code",
507
+ "execution_count": null,
508
+ "id": "ac7c2025-c7d5-4141-837d-c34b6defcbf7",
509
+ "metadata": {},
510
+ "outputs": [],
511
+ "source": []
512
+ },
513
+ {
514
+ "cell_type": "code",
515
+ "execution_count": 32,
516
+ "id": "abf9d28d-8903-41ca-829f-8632d35b9b20",
517
+ "metadata": {},
518
+ "outputs": [],
519
+ "source": [
520
+ "kolmflow2D_scenario = apebench.scenarios.physical.KolmogorovFlow(\n",
521
+ " \n",
522
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
523
+ "\n",
524
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
525
+ " \n",
526
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
527
+ "\n",
528
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
529
+ " \n",
530
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
531
+ " \n",
532
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
533
+ "\n",
534
+ " train_seed = 0,\n",
535
+ "\n",
536
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
537
+ " \n",
538
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
539
+ "\n",
540
+ " test_seed = 773,\n",
541
+ ")"
542
+ ]
543
+ },
544
+ {
545
+ "cell_type": "code",
546
+ "execution_count": 33,
547
+ "id": "8c1d6fa7-d085-49cf-8bc9-67f391d8f95f",
548
+ "metadata": {},
549
+ "outputs": [
550
+ {
551
+ "name": "stdout",
552
+ "output_type": "stream",
553
+ "text": [
554
+ "train data shape (100, 51, 1, 128, 128)\n",
555
+ "test ICs shape (40, 1, 128, 128)\n",
556
+ "complete test data shape (40, 201, 1, 128, 128)\n",
557
+ "val data (10, 51, 1, 128, 128)\n",
558
+ "test data after removing val (30, 201, 1, 128, 128)\n"
559
+ ]
560
+ }
561
+ ],
562
+ "source": [
563
+ "# data from NS-kolm flow\n",
564
+ "train_data = kolmflow2D_scenario.get_train_data()\n",
565
+ "print('train data shape',train_data.shape)\n",
566
+ "\n",
567
+ "test_ic_set = kolmflow2D_scenario.get_test_ic_set()\n",
568
+ "print('test ICs shape',test_ic_set.shape)\n",
569
+ "\n",
570
+ "full_test_data = kolmflow2D_scenario.get_test_data() \n",
571
+ "print('complete test data shape',full_test_data.shape)\n",
572
+ "\n",
573
+ "val_data = full_test_data[:10,:51,:,:]\n",
574
+ "print('val data',val_data.shape)\n",
575
+ "\n",
576
+ "test_data = full_test_data[10:,:,:,:]\n",
577
+ "print('test data after removing val',test_data.shape)"
578
+ ]
579
+ },
580
+ {
581
+ "cell_type": "code",
582
+ "execution_count": 34,
583
+ "id": "fe45d76b-9a8f-4998-aba9-2685f8ba1ad8",
584
+ "metadata": {},
585
+ "outputs": [],
586
+ "source": [
587
+ "# jnp.save(\"kolmflow2D_train_data_128x128_100ic_50t.npy\", train_data)\n",
588
+ "# jnp.save(\"kolmflow2D/kolmflow2D_val_data_128x128_10ic_50t.npy\", val_data)\n",
589
+ "# jnp.save(\"kolmflow2D/kolmflow2D_test_data_128x128_30ic_200t.npy\", test_data)\n"
590
+ ]
591
+ },
592
+ {
593
+ "cell_type": "code",
594
+ "execution_count": null,
595
+ "id": "e8111538-d4b8-464f-9c0e-e3758d89a5d6",
596
+ "metadata": {},
597
+ "outputs": [],
598
+ "source": []
599
+ },
600
+ {
601
+ "cell_type": "code",
602
+ "execution_count": 35,
603
+ "id": "51fbdc8d-4a44-465b-85e1-19e15d965350",
604
+ "metadata": {},
605
+ "outputs": [],
606
+ "source": [
607
+ "grayscott2D_scenario = apebench.scenarios.physical.GrayScott(\n",
608
+ " \n",
609
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
610
+ "\n",
611
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
612
+ " \n",
613
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
614
+ "\n",
615
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
616
+ " \n",
617
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
618
+ " \n",
619
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
620
+ "\n",
621
+ " train_seed = 0,\n",
622
+ "\n",
623
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
624
+ " \n",
625
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
626
+ "\n",
627
+ " test_seed = 773,\n",
628
+ ")"
629
+ ]
630
+ },
631
+ {
632
+ "cell_type": "code",
633
+ "execution_count": 36,
634
+ "id": "d1482cd8-1651-4bd0-9ed3-52729d424f6f",
635
+ "metadata": {},
636
+ "outputs": [
637
+ {
638
+ "name": "stdout",
639
+ "output_type": "stream",
640
+ "text": [
641
+ "train data shape (100, 51, 2, 128, 128)\n",
642
+ "test ICs shape (40, 2, 128, 128)\n",
643
+ "complete test data shape (40, 201, 2, 128, 128)\n",
644
+ "val data (10, 51, 2, 128, 128)\n",
645
+ "test data after removing val (30, 201, 2, 128, 128)\n"
646
+ ]
647
+ }
648
+ ],
649
+ "source": [
650
+ "# data from gray scott\n",
651
+ "train_data = grayscott2D_scenario.get_train_data()\n",
652
+ "print('train data shape',train_data.shape)\n",
653
+ "\n",
654
+ "test_ic_set = grayscott2D_scenario.get_test_ic_set()\n",
655
+ "print('test ICs shape',test_ic_set.shape)\n",
656
+ "\n",
657
+ "full_test_data = grayscott2D_scenario.get_test_data() # [:,1:,:,:] # removing the initial condition from test set\n",
658
+ "print('complete test data shape',full_test_data.shape)\n",
659
+ "\n",
660
+ "val_data = full_test_data[:10,:51,:,:]\n",
661
+ "print('val data',val_data.shape)\n",
662
+ "\n",
663
+ "test_data = full_test_data[10:,:,:,:]\n",
664
+ "print('test data after removing val',test_data.shape)\n",
665
+ "\n"
666
+ ]
667
+ },
668
+ {
669
+ "cell_type": "code",
670
+ "execution_count": 38,
671
+ "id": "8e53499e-2242-4de9-8738-be9cf4b93ea1",
672
+ "metadata": {},
673
+ "outputs": [],
674
+ "source": [
675
+ "# jnp.save(\"grayscott2D_train_data_128x128_100ic_50t.npy\", train_data)\n",
676
+ "# jnp.save(\"grayscott2D_val_data_128x128_10ic_50t.npy\", val_data)\n",
677
+ "# jnp.save(\"grayscott2D_test_data_128x128_30ic_200t.npy\", test_data)\n"
678
+ ]
679
+ },
680
+ {
681
+ "cell_type": "code",
682
+ "execution_count": 39,
683
+ "id": "39124165-aa63-433b-b81f-6ca560db10ed",
684
+ "metadata": {},
685
+ "outputs": [],
686
+ "source": [
687
+ "dypdiff2D_scenario = apebench.scenarios.difficulty.HyperDiffusion(\n",
688
+ " \n",
689
+ " optim_config=\"adam;10_000;constant;1e-4\",\n",
690
+ "\n",
691
+ " report_metrics=\"mean_nRMSE\", # \"mean_nRMSE,mean_fourier_nRMSE;0;5;0,mean_H1_nRMSE\"\n",
692
+ " \n",
693
+ " num_points = spatial_grid_points, # discretized points on the spatial \n",
694
+ "\n",
695
+ " num_spatial_dims = spatial_dims, # spatial dimensions \n",
696
+ " \n",
697
+ " num_train_samples = num_train_samples, # number of ICs for train set\n",
698
+ " \n",
699
+ " train_temporal_horizon = train_time_steps, # consecutive time steps the simulator is run\n",
700
+ "\n",
701
+ " train_seed = 0,\n",
702
+ "\n",
703
+ " num_test_samples = num_test_samples, # number of ICs for test set\n",
704
+ " \n",
705
+ " test_temporal_horizon = test_time_steps, # consecutive time steps the simulator is run for test set\n",
706
+ "\n",
707
+ " test_seed = 773,\n",
708
+ ")"
709
+ ]
710
+ },
711
+ {
712
+ "cell_type": "code",
713
+ "execution_count": 40,
714
+ "id": "9e5a8c4c-fe32-4e49-9504-bd423d5deb95",
715
+ "metadata": {},
716
+ "outputs": [
717
+ {
718
+ "name": "stdout",
719
+ "output_type": "stream",
720
+ "text": [
721
+ "train data shape (100, 51, 1, 128, 128)\n",
722
+ "test ICs shape (40, 1, 128, 128)\n",
723
+ "complete test data shape (30, 201, 2, 128, 128)\n",
724
+ "val data (10, 51, 1, 128, 128)\n",
725
+ "test data after removing val (30, 201, 1, 128, 128)\n"
726
+ ]
727
+ }
728
+ ],
729
+ "source": [
730
+ "# data from hyper diffusion\n",
731
+ "train_data = dypdiff2D_scenario.get_train_data()\n",
732
+ "print('train data shape',train_data.shape)\n",
733
+ "\n",
734
+ "test_ic_set = dypdiff2D_scenario.get_test_ic_set()\n",
735
+ "print('test ICs shape',test_ic_set.shape)\n",
736
+ "\n",
737
+ "full_test_data = dypdiff2D_scenario.get_test_data() # [:,1:,:,:] # removing the initial condition from test set\n",
738
+ "print('complete test data shape',test_data.shape)\n",
739
+ "\n",
740
+ "val_data = full_test_data[:10,:51,:,:]\n",
741
+ "print('val data',val_data.shape)\n",
742
+ "\n",
743
+ "test_data = full_test_data[10:,:,:,:]\n",
744
+ "print('test data after removing val',test_data.shape)"
745
+ ]
746
+ },
747
+ {
748
+ "cell_type": "code",
749
+ "execution_count": 41,
750
+ "id": "1916cc3d-342c-4aaa-8e0a-48fdea75ced7",
751
+ "metadata": {},
752
+ "outputs": [],
753
+ "source": [
754
+ "# jnp.save(\"dypdiff2D_train_data_128x128_100ic_50t.npy\", train_data)\n",
755
+ "# jnp.save(\"dypdiff2D_val_data_128x128_10ic_50t.npy\", val_data)\n",
756
+ "# jnp.save(\"dypdiff2D_test_data_128x128_30ic_200t.npy\", test_data)\n"
757
+ ]
758
+ }
759
+ ],
760
+ "metadata": {
761
+ "kernelspec": {
762
+ "display_name": "Python (apebench)",
763
+ "language": "python",
764
+ "name": "apebench"
765
+ },
766
+ "language_info": {
767
+ "codemirror_mode": {
768
+ "name": "ipython",
769
+ "version": 3
770
+ },
771
+ "file_extension": ".py",
772
+ "mimetype": "text/x-python",
773
+ "name": "python",
774
+ "nbconvert_exporter": "python",
775
+ "pygments_lexer": "ipython3",
776
+ "version": "3.12.9"
777
+ }
778
+ },
779
+ "nbformat": 4,
780
+ "nbformat_minor": 5
781
+ }