Skip to content

Commit dc1c604

Browse files
[Doc] Add anno for eval (#863)
* add annotation for eval.py * add NLS example into index and README
1 parent 6fb27c0 commit dc1c604

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ PaddleScience 是一个基于深度学习框架 PaddlePaddle 开发的科学计
2626
| 问题类型 | 案例名称 | 优化算法 | 模型类型 | 训练方式 | 数据集 | 参考资料 |
2727
|-----|---------|-----|---------|----|---------|---------|
2828
| 微分方程 | [拉普拉斯方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/laplace2d) | 机理驱动 | MLP | 无监督学习 | - | - |
29-
| 微分方程 | [伯格斯方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/deephpms) | 机理驱动 | MLP | 无监督学习 | [Data](https://github.com/maziarraissi/DeepHPMs/tree/master/Data) | [Paper](https://arxiv.org/pdf/1801.06637.pdf) |</center>
29+
| 微分方程 | [伯格斯方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/deephpms) | 机理驱动 | MLP | 无监督学习 | [Data](https://github.com/maziarraissi/DeepHPMs/tree/master/Data) | [Paper](https://arxiv.org/pdf/1801.06637.pdf) |
3030
| 微分方程 | [非线性偏微分方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/pirbn) | 机理驱动 | PIRBN | 无监督学习 | - | [Paper](https://arxiv.org/abs/2304.06234) |
3131
| 微分方程 | [洛伦兹方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/lorenz) | 数据驱动 | Transformer-Physx | 监督学习 | [Data](https://github.com/zabaras/transformer-physx) | [Paper](https://arxiv.org/abs/2010.03957) |
3232
| 微分方程 | [若斯叻方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/rossler) | 数据驱动 | Transformer-Physx | 监督学习 | [Data](https://github.com/zabaras/transformer-physx) | [Paper](https://arxiv.org/abs/2010.03957) |
3333
| 算子学习 | [DeepONet](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/deeponet) | 数据驱动 | MLP | 监督学习 | [Data](https://deepxde.readthedocs.io/en/latest/demos/operator/antiderivative_unaligned.html) | [Paper](https://export.arxiv.org/pdf/1910.03193.pdf) |
3434
| 微分方程 | [梯度增强的物理知识融合 PDE 求解](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/gpinn/poisson_1d.py) | 机理驱动 | gPINN | 无监督学习 | - | [Paper](https://doi.org/10.1016/j.cma.2022.114823) |
3535
| 积分方程 | [沃尔泰拉积分方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/volterra_ide) | 机理驱动 | MLP | 无监督学习 | - | [Project](https://github.com/lululxvi/deepxde/blob/master/examples/pinn_forward/Volterra_IDE.py) |
3636
| 微分方程 | [分数阶微分方程](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/fpde/fractional_poisson_2d.py) | 机理驱动 | MLP | 无监督学习 | - | - |
37+
| 光孤子 | [Optical soliton](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/nlsmb) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|
38+
| 光纤怪波 | [Optical rogue wave](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/nlsmb) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|
3739

3840
<br>
3941
<p align="center"><b>技术科学(AI for Technology)</b></p>

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
| 微分方程 | [梯度增强的物理知识融合 PDE 求解](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/gpinn/poisson_1d.py) | 机理驱动 | gPINN | 无监督学习 | - | [Paper](https://doi.org/10.1016/j.cma.2022.114823) |
8080
| 积分方程 | [沃尔泰拉积分方程](./zh/examples/volterra_ide.md) | 机理驱动 | MLP | 无监督学习 | - | [Project](https://github.com/lululxvi/deepxde/blob/master/examples/pinn_forward/Volterra_IDE.py) |
8181
| 微分方程 | [分数阶微分方程](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/fpde/fractional_poisson_2d.py) | 机理驱动 | MLP | 无监督学习 | - | - |
82+
| 光孤子 | [Optical soliton](./zh/examples/nlsmb.md) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|
83+
| 光纤怪波 | [Optical rogue wave](./zh/examples/nlsmb.md) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|
8284

8385
<br>
8486
<p align="center"><b>技术科学(AI for Technology)</b></p>

ppsci/solver/eval.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def _eval_by_dataset(
6363
) -> Tuple[float, Dict[str, Dict[str, float]]]:
6464
"""Evaluate with computing metric on total samples(default process).
6565
66+
NOTE: This is the default evaluation method as general for most cases, but may not
67+
memory-efficiency for large dataset or large output.
68+
6669
Args:
6770
solver (solver.Solver): Main Solver.
6871
epoch_id (int): Epoch id.
@@ -159,6 +162,7 @@ def _eval_by_dataset(
159162

160163
metric_dict_group: Dict[str, Dict[str, float]] = misc.PrettyOrderedDict()
161164
for metric_name, metric_func in _validator.metric.items():
165+
# NOTE: compute metric with entire output and label
162166
metric_dict = metric_func(all_output, all_label)
163167
metric_dict_group[metric_name] = {
164168
k: float(v) for k, v in metric_dict.items()
@@ -189,6 +193,10 @@ def _eval_by_batch(
189193
) -> Tuple[float, Dict[str, Dict[str, float]]]:
190194
"""Evaluate with computing metric by batch, which is memory-efficient.
191195
196+
NOTE: This is a evaluation function for large dataset or large output, as is more
197+
memory-efficiency than evaluating by dataset, but less general because some metric
198+
is not independent among samples, e.g. L2 relative error.
199+
192200
Args:
193201
solver (solver.Solver): Main Solver.
194202
epoch_id (int): Epoch id.
@@ -270,7 +278,10 @@ def _eval_by_batch(
270278
# concatenate all metric and discard metric of padded sample(s)
271279
for metric_name, metric_dict in metric_dict_group.items():
272280
for var_name, metric_value in metric_dict.items():
281+
# NOTE: concat all metric(scalars) into metric vector
273282
metric_value = paddle.concat(metric_value)[:num_samples]
283+
# NOTE: compute metric via averaging metric vector,
284+
# this might be not general for certain evaluation case
274285
metric_value = float(metric_value.mean())
275286
metric_dict_group[metric_name][var_name] = metric_value
276287
metric_str = f"{_validator.name}/{metric_name}.{var_name}"

0 commit comments

Comments
 (0)