Skip to content

Commit e580dca

Browse files
[Feature&Doc] Add ijcai code url (#968)
* support setting iters_per_epoch -1 fo adaptive length of dataloader * update ijcai2024 code url * change install order
1 parent 757b94f commit e580dca

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
[**PaddleScience使用文档**](https://paddlescience-docs.readthedocs.io/zh-cn/latest/)
1515

16-
🔥 [IJCAI 2024: 任意三维几何外形车辆的风阻快速预测竞赛](https://competition.atomgit.com/competitionInfo?id=7f3f276465e9e845fd3a811d2d6925b5),欢迎报名参赛。
16+
🔥 [IJCAI 2024: 任意三维几何外形车辆的风阻快速预测竞赛](https://competition.atomgit.com/competitionInfo?id=7f3f276465e9e845fd3a811d2d6925b5),track A, B, C 代码:
17+
18+
- [paddle实现](../jointContribution/IJCAI_2024/README.md)
19+
- [pytorch实现](https://competition.atomgit.com/competitionInfo?id=7f3f276465e9e845fd3a811d2d6925b5)(点击**排行榜**可查看各个赛道前10名的代码)
1720

1821
<!-- --8<-- [start:description] -->
1922
## 👀简介
@@ -168,13 +171,13 @@ python -c "import paddle; paddle.utils.run_check()"
168171

169172
- pip 安装
170173

171-
执行以下命令以 pip 的方式安装 nightly build / release 版本的 PaddleScience。
174+
执行以下命令以 pip 的方式安装 release / nightly build 版本的 PaddleScience。
172175
<!-- --8<-- [start:pip_install] -->
173176
``` shell
174-
# nightly build
175-
pip install https://paddle-qa.bj.bcebos.com/PaddleScience/whl/latest/dist/paddlesci-0.0.0-py3-none-any.whl
176177
# release
177-
# pip install -U paddlesci
178+
pip install -U paddlesci
179+
# nightly build
180+
# pip install https://paddle-qa.bj.bcebos.com/PaddleScience/whl/latest/dist/paddlesci-0.0.0-py3-none-any.whl
178181
```
179182
<!-- --8<-- [end:pip_install] -->
180183

docs/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
./README.md:status
55
--8<--
66

7-
🔥 [IJCAI 2024: 任意三维几何外形车辆的风阻快速预测竞赛](https://competition.atomgit.com/competitionInfo?id=7f3f276465e9e845fd3a811d2d6925b5),欢迎报名参赛。
7+
🔥 [IJCAI 2024: 任意三维几何外形车辆的风阻快速预测竞赛](https://competition.atomgit.com/competitionInfo?id=7f3f276465e9e845fd3a811d2d6925b5),track A, B, C 代码:
8+
9+
- [paddle实现](../jointContribution/IJCAI_2024/README.md)
10+
- [pytorch实现](https://competition.atomgit.com/competitionInfo?id=7f3f276465e9e845fd3a811d2d6925b5)(点击**排行榜**可查看各个赛道前10名的代码)
811

912
<style>
1013
.container {
@@ -158,7 +161,7 @@
158161
=== "方式2: pip安装"
159162

160163
``` sh
161-
pip install paddlesci
164+
pip install -U paddlesci
162165
```
163166

164167
**完整安装流程**[安装与使用](./zh/install_setup.md)

ppsci/solver/solver.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ class Solver:
6969
optimizer (Optional[optimizer.Optimizer]): Optimizer object. Defaults to None.
7070
lr_scheduler (Optional[optimizer.lr.LRScheduler]): Learning rate scheduler. Defaults to None.
7171
epochs (int, optional): Training epoch(s). Defaults to 5.
72-
iters_per_epoch (int, optional): Number of iterations within an epoch. Defaults to 20.
72+
iters_per_epoch (int, optional): Number of iterations within an epoch. If set to -1,
73+
than will be automatically set to the length of dataloader of given constraint.
74+
Defaults to 20.
7375
update_freq (int, optional): Update frequency of parameters. Defaults to 1.
7476
save_freq (int, optional): Saving frequency for checkpoint. Defaults to 0.
7577
log_freq (int, optional): Logging frequency. Defaults to 10.
@@ -215,6 +217,18 @@ def __init__(
215217
self.start_eval_epoch = start_eval_epoch
216218
self.eval_freq = eval_freq
217219

220+
if self.iters_per_epoch == -1 and self.constraint is not None:
221+
if len(self.constraint) != 1:
222+
raise NotImplementedError(
223+
f"Multiple({len(self.constraint)}) constraints are detected, "
224+
"which is not supported yet, when 'iters_per_epoch' is set to -1."
225+
)
226+
self.iters_per_epoch = len(next(iter(self.constraint.values())).data_loader)
227+
logger.message(
228+
"Detected 'iters_per_epoch' is set to -1, 'iters_per_epoch' is now "
229+
f"reset to the length of dataloader({self.iters_per_epoch}) of given constraint."
230+
)
231+
218232
# initialize training log(training loss, time cost, etc.) recorder during one epoch
219233
self.train_output_info: Dict[str, misc.AverageMeter] = {}
220234
self.train_time_info = {

ppsci/utils/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,15 @@ def epochs_check(cls, v):
116116

117117
@field_validator("iters_per_epoch")
118118
def iters_per_epoch_check(cls, v):
119-
if v <= 0:
119+
if v <= 0 and v != -1:
120120
raise ValueError(
121-
"'TRAIN.iters_per_epoch' should be a positive integer when is type of int"
122-
f", but got {v}"
121+
f"'TRAIN.iters_per_epoch' received an invalid value({v}), "
122+
"but is expected one of: \n"
123+
"* A positive integer, to manually specify the number of iterations per epoch, "
124+
"which is commonly used in PINN training.\n"
125+
"* -1, to automatically set the number of iterations per epoch to "
126+
"the length of dataloader of given constraint, which is commonly "
127+
f"used in data-driven training.\n"
123128
)
124129
return v
125130

0 commit comments

Comments
 (0)