Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ PaddleScience 是一个基于深度学习框架 PaddlePaddle 开发的科学计
| 问题类型 | 案例名称 | 优化算法 | 模型类型 | 训练方式 | 数据集 | 参考资料 |
|-----|---------|-----|---------|----|---------|---------|
| 微分方程 | [拉普拉斯方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/laplace2d) | 机理驱动 | MLP | 无监督学习 | - | - |
| 微分方程 | [伯格斯方程](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>
| 微分方程 | [伯格斯方程](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) |
| 微分方程 | [非线性偏微分方程](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/pirbn) | 机理驱动 | PIRBN | 无监督学习 | - | [Paper](https://arxiv.org/abs/2304.06234) |
| 微分方程 | [洛伦兹方程](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) |
| 微分方程 | [若斯叻方程](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) |
| 算子学习 | [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) |
| 微分方程 | [梯度增强的物理知识融合 PDE 求解](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/gpinn/poisson_1d.py) | 机理驱动 | gPINN | 无监督学习 | - | [Paper](https://doi.org/10.1016/j.cma.2022.114823) |
| 积分方程 | [沃尔泰拉积分方程](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) |
| 微分方程 | [分数阶微分方程](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/fpde/fractional_poisson_2d.py) | 机理驱动 | MLP | 无监督学习 | - | - |
| 光孤子 | [Optical soliton](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/nlsmb) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|
| 光纤怪波 | [Optical rogue wave](https://paddlescience-docs.readthedocs.io/zh/latest/zh/examples/nlsmb) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|

<br>
<p align="center"><b>技术科学(AI for Technology)</b></p>
Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
| 微分方程 | [梯度增强的物理知识融合 PDE 求解](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/gpinn/poisson_1d.py) | 机理驱动 | gPINN | 无监督学习 | - | [Paper](https://doi.org/10.1016/j.cma.2022.114823) |
| 积分方程 | [沃尔泰拉积分方程](./zh/examples/volterra_ide.md) | 机理驱动 | MLP | 无监督学习 | - | [Project](https://github.com/lululxvi/deepxde/blob/master/examples/pinn_forward/Volterra_IDE.py) |
| 微分方程 | [分数阶微分方程](https://github.com/PaddlePaddle/PaddleScience/blob/develop/examples/fpde/fractional_poisson_2d.py) | 机理驱动 | MLP | 无监督学习 | - | - |
| 光孤子 | [Optical soliton](./zh/examples/nlsmb.md) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|
| 光纤怪波 | [Optical rogue wave](./zh/examples/nlsmb.md) | 机理驱动 | MLP | 无监督学习 | - | [Paper](https://doi.org/10.1007/s11071-023-08824-w)|

<br>
<p align="center"><b>技术科学(AI for Technology)</b></p>
Expand Down
11 changes: 11 additions & 0 deletions ppsci/solver/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def _eval_by_dataset(
) -> Tuple[float, Dict[str, Dict[str, float]]]:
"""Evaluate with computing metric on total samples(default process).

NOTE: This is the default evaluation method as general for most cases, but may not
memory-efficiency for large dataset or large output.

Args:
solver (solver.Solver): Main Solver.
epoch_id (int): Epoch id.
Expand Down Expand Up @@ -159,6 +162,7 @@ def _eval_by_dataset(

metric_dict_group: Dict[str, Dict[str, float]] = misc.PrettyOrderedDict()
for metric_name, metric_func in _validator.metric.items():
# NOTE: compute metric with entire output and label
metric_dict = metric_func(all_output, all_label)
metric_dict_group[metric_name] = {
k: float(v) for k, v in metric_dict.items()
Expand Down Expand Up @@ -189,6 +193,10 @@ def _eval_by_batch(
) -> Tuple[float, Dict[str, Dict[str, float]]]:
"""Evaluate with computing metric by batch, which is memory-efficient.

NOTE: This is a evaluation function for large dataset or large output, as is more
memory-efficiency than evaluating by dataset, but less general because some metric
is not independent among samples, e.g. L2 relative error.

Args:
solver (solver.Solver): Main Solver.
epoch_id (int): Epoch id.
Expand Down Expand Up @@ -270,7 +278,10 @@ def _eval_by_batch(
# concatenate all metric and discard metric of padded sample(s)
for metric_name, metric_dict in metric_dict_group.items():
for var_name, metric_value in metric_dict.items():
# NOTE: concat all metric(scalars) into metric vector
metric_value = paddle.concat(metric_value)[:num_samples]
# NOTE: compute metric via averaging metric vector,
# this might be not general for certain evaluation case
metric_value = float(metric_value.mean())
metric_dict_group[metric_name][var_name] = metric_value
metric_str = f"{_validator.name}/{metric_name}.{var_name}"
Expand Down