Skip to content

Commit

Permalink
[Doc] Update url (PaddlePaddle#966)
Browse files Browse the repository at this point in the history
* update SPINN url

* update url

* annotate latex which may occur error when latex font is not installed

* add mtl submodule to loss.__all__

* update doc

* update pre-commit guidance

* update synchronization of upstream guidance

* update docs

* update batch size computation

* rename IJACA -> IJCAI

* update description

* remove redundant import
  • Loading branch information
HydrogenSulfate authored Aug 10, 2024
1 parent 2436c5a commit 757b94f
Show file tree
Hide file tree
Showing 71 changed files with 63 additions and 20 deletions.
17 changes: 14 additions & 3 deletions docs/zh/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,18 @@ PaddleScience 文档基于 [Mkdocs-Material](https://squidfunk.github.io/mkdocs-
### 3.4 预览文档
`PaddleScience/` 目录下执行以下命令,等待构建完成后,点击显示的链接进入本地网页预览文档内容。
假设撰写好的文档位置为 `PaddleScience/docs/zh/examples/your_exmaple.md`,为了让其在 PaddleScience 官网 [经典案例](https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/examples/allen_cahn/) 左侧目录中展示,需要修改 `PaddleScience/mkdocs.yml`。将 `your_exmaple.md` 的相对路径仿照其他案例,添加到 `- 经典案例:` 下的列表中,如下高亮行所示。
``` yaml hl_lines="23" title="PaddleScience/mkdocs.yml"
...
--8<--
mkdocs.yml:38:58
--8<--
- EXAMPLE_NAME: docs/zh/examples/your_exmaple.md
...
```
然后在 `PaddleScience/` 目录下执行以下命令,等待构建完成后,点击显示的链接进入本地网页预览文档内容。
``` sh
mkdocs serve
Expand Down Expand Up @@ -944,11 +955,11 @@ mkdocs serve
### 4.2 同步上游代码
在开发过程中,上游代码可能经过更新,因此需要执行以下命令,先将上游的最新代码拉取下来,合并到当前代码中,与上游最新代码进行同步。
在开发过程中,上游代码可能经过更新,因此需要执行以下命令,将上游的最新代码拉取下来,合并到当前代码中,与上游最新代码进行同步。
``` sh
git remote add upstream https://github.com/PaddlePaddle/PaddleScience.git
git fetch upstream upstream_develop
git fetch upstream develop:upstream_develop
git merge upstream_develop
```
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/examples/allen_cahn.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ examples/allen_cahn/allen_cahn_piratenet.py:138:156
--8<--
```

### 3.9 模型训练、评估与可视化
### 3.8 模型训练、评估与可视化

完成上述设置之后,只需要将上述实例化的对象按顺序传递给 `ppsci.solver.Solver`,然后启动训练、评估、可视化。

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# IJACA_Code
The paddle version of the top three in each track of the IJACA 2024 competition.
# IJCAI_Code

The paddle version of the top three in each track of the IJCAI 2024 competition.

Inference codes only now.

## Dataset

Please refer to the .ipynb files in each directory to download the data and set the corresponding parameters.

## Checkpoint

Donwload checkpoints:

``` sh
cd PaddleScience/jointContribution/IJACA_2024
cd PaddleScience/jointContribution/IJCAI_2024
# linux
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJACA_2024_ckpts.tar.gz
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJCAI_2024_ckpts.tar.gz
# windows
# curl https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJACA_2024_ckpts.tar.gz
# curl https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJCAI_2024_ckpts.tar.gz
```

Unzip the checkpoints and move them to the corresponding directory:

``` sh
tar -xvzf IJACA_2024_ckpts.tar.gz
tar -xvzf IJCAI_2024_ckpts.tar.gz

# aminos
mkdir -p ./aminos/Logger/states/
Expand All @@ -40,17 +45,21 @@ mv ./ckpts/bju/pretrained_checkpoint.pdparams ./bju/pretrained_checkpoint.pdpara
```

## Inference

First enter the corresponding directory. For example "aminos":

``` sh
cd aminos
```

Install requirements:

``` sh
pip install -r requirements.txt
```

Run Inference:

``` py
### aminos
python infer.py --dataset_dir "./Datasets" --load_index="90"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2366,8 +2366,8 @@
"metadata": {},
"outputs": [],
"source": [
"!wget https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJACA_2024_ckpts.tar.gz\n",
"!tar -zxvf IJACA_2024_ckpts.tar.gz\n",
"!wget https://paddle-org.bj.bcebos.com/paddlescience/models/contrib/IJCAI_2024_ckpts.tar.gz\n",
"!tar -zxvf IJCAI_2024_ckpts.tar.gz\n",
"! mv ckpts/bju/geom/ckpt/checkpoint_pointbert.pdparams ./geom/ckpt/checkpoint_pointbert.pdparams"
]
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 2 additions & 5 deletions ppsci/solver/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import datetime
from typing import TYPE_CHECKING
from typing import Dict
from typing import Optional

from paddle import device

Expand Down Expand Up @@ -114,7 +111,7 @@ def log_train_info(
def log_eval_info(
solver: "solver.Solver",
batch_size: int,
epoch_id: int,
epoch_id: Optional[int],
iters_per_epoch: int,
iter_id: int,
):
Expand Down
30 changes: 28 additions & 2 deletions ppsci/solver/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import sys
import time
from typing import TYPE_CHECKING
from typing import Dict
from typing import Sequence
from typing import Union

import paddle
from paddle.distributed.fleet.utils import hybrid_parallel_util as hpu
Expand All @@ -29,6 +32,29 @@
from ppsci import solver


def _compute_batch_size(
input_dict: Dict[str, Union[paddle.Tensor, Sequence[paddle.Tensor]]]
) -> int:
"""Compute batch size from given input dict.
NOTE: Returned `batch_size` might be inaccurate, but it won't affect the correctness
of the training results because `batch_size` is now only used for timing.
Args:
input_dict (Dict[str, Union[paddle.Tensor, Sequence[paddle.Tensor]]]): Given input dict.
Returns:
int: Batch size of input dict.
"""
sample = next(iter(input_dict.values()))
if hasattr(sample, "shape"):
return sample.shape[0]
elif hasattr(sample, "__len__"): # Might be inaccurate here.
return len(sample)
else:
raise ValueError("Unsupported type of input dict value.")


def train_epoch_func(solver: "solver.Solver", epoch_id: int, log_freq: int):
"""Train program for one epoch.
Expand Down Expand Up @@ -77,7 +103,7 @@ def train_epoch_func(solver: "solver.Solver", epoch_id: int, log_freq: int):
input_dicts.append(input_dict)
label_dicts.append(label_dict)
weight_dicts.append(weight_dict)
total_batch_size += next(iter(input_dict.values())).shape[0]
total_batch_size += _compute_batch_size(input_dict)
reader_tic = time.perf_counter()

loss_dict = misc.Prettydefaultdict(float)
Expand Down Expand Up @@ -227,7 +253,7 @@ def train_LBFGS_epoch_func(solver: "solver.Solver", epoch_id: int, log_freq: int
input_dicts.append(input_dict)
label_dicts.append(label_dict)
weight_dicts.append(weight_dict)
total_batch_size += next(iter(input_dict.values())).shape[0]
total_batch_size += _compute_batch_size(input_dict)
reader_tic = time.perf_counter()

def closure() -> paddle.Tensor:
Expand Down
2 changes: 1 addition & 1 deletion ppsci/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def check_flag_enabled(flag_name: str) -> bool:
"""Check whether the flag is enabled.
Args:
flag_name(str): Flag name to be checked whether enabled or disabled.
flag_name (str): Flag name to be checked whether enabled or disabled.
Returns:
bool: Whether given flag name is enabled in environment.
Expand Down

0 comments on commit 757b94f

Please sign in to comment.