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
12 changes: 6 additions & 6 deletions docs/zh/examples/amgnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ unzip data.zip

=== "airfoil"

``` yaml linenums="41"
``` yaml linenums="50"
--8<--
examples/amgnet/conf/amgnet_airfoil.yaml:41:51
examples/amgnet/conf/amgnet_airfoil.yaml:50:52
--8<--
```

=== "cylinder"

``` yaml linenums="41"
``` yaml linenums="50"
--8<--
examples/amgnet/conf/amgnet_cylinder.yaml:41:51
examples/amgnet/conf/amgnet_cylinder.yaml:50:52
--8<--
```

Expand Down Expand Up @@ -280,14 +280,14 @@ unzip data.zip

``` py linenums="138"
--8<--
examples/amgnet/amgnet_airfoil.py:138:
examples/amgnet/amgnet_airfoil.py:138:151
--8<--
```
=== "cylinder"

``` py linenums="138"
--8<--
examples/amgnet/amgnet_cylinder.py:138:
examples/amgnet/amgnet_cylinder.py:138:151
--8<--
```

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/examples/phylstm.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ examples/phylstm/phylstm2.py:148:170

接下来我们需要指定训练轮数,此处我们按实验经验,使用 100 轮训练轮数。

``` yaml linenums="39"
``` yaml linenums="38"
--8<--
examples/phylstm/conf/phylstm2.yaml:39:39
examples/phylstm/conf/phylstm2.yaml:38:40
--8<--
```

Expand Down
28 changes: 14 additions & 14 deletions examples/deepcfd/deepcfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import hydra
import numpy as np
import paddle
from matplotlib import pyplot as plt
from omegaconf import DictConfig

Expand All @@ -34,7 +35,9 @@ def split_tensors(

Args:
tensors (List[np.array]): Non-empty tensor list.
ratio (float): Split ratio. For example, tensor list A is split to A1 and A2. len(A1) / len(A) = ratio.
ratio (float): Split ratio. For example, tensor list A is split to A1 and A2.
len(A1) / len(A) = ratio.

Returns:
Tuple[List[np.array], List[np.array]]: Split tensors.
"""
Expand Down Expand Up @@ -192,10 +195,7 @@ def predict_and_save_plot(
plt.colorbar(orientation="horizontal")
plt.tight_layout()
plt.show()
plt.savefig(
os.path.join(plot_dir, f"cfd_{index}.png"),
bbox_inches="tight",
)
plt.savefig(os.path.join(plot_dir, f"cfd_{index}.png"), bbox_inches="tight")


def train(cfg: DictConfig):
Expand Down Expand Up @@ -376,17 +376,17 @@ def evaluate(cfg: DictConfig):

# define loss
def loss_expr(
output_dict: Dict[str, np.ndarray],
label_dict: Dict[str, np.ndarray] = None,
weight_dict: Dict[str, np.ndarray] = None,
) -> float:
output_dict: Dict[str, "paddle.Tensor"],
label_dict: Dict[str, "paddle.Tensor"] = None,
weight_dict: Dict[str, "paddle.Tensor"] = None,
) -> Dict[str, "paddle.Tensor"]:
output = output_dict["output"]
y = label_dict["output"]
loss_u = (output[:, 0:1, :, :] - y[:, 0:1, :, :]) ** 2
loss_v = (output[:, 1:2, :, :] - y[:, 1:2, :, :]) ** 2
loss_p = (output[:, 2:3, :, :] - y[:, 2:3, :, :]).abs()
loss = (loss_u + loss_v + loss_p) / CHANNELS_WEIGHTS
return loss.sum()
return {"custom_loss": loss.sum()}

# manually build validator
eval_dataloader_cfg = {
Expand All @@ -404,10 +404,10 @@ def loss_expr(
}

def metric_expr(
output_dict: Dict[str, np.ndarray],
label_dict: Dict[str, np.ndarray] = None,
weight_dict: Dict[str, np.ndarray] = None,
) -> Dict[str, float]:
output_dict: Dict[str, "paddle.Tensor"],
label_dict: Dict[str, "paddle.Tensor"] = None,
weight_dict: Dict[str, "paddle.Tensor"] = None,
) -> Dict[str, "paddle.Tensor"]:
output = output_dict["output"]
y = label_dict["output"]
total_mse = ((output - y) ** 2).sum() / len(test_x)
Expand Down
19 changes: 10 additions & 9 deletions examples/phylstm/conf/phylstm2.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
defaults:
- ppsci_default
- TRAIN: train_default
- TRAIN/ema: ema_default
- TRAIN/swa: swa_default
- EVAL: eval_default
- INFER: infer_default
- hydra/job/config/override_dirname/exclude_keys: exclude_keys_default
- _self_

hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_PhyLSTM2/${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
config:
override_dirname:
exclude_keys:
- TRAIN.checkpoint_path
- TRAIN.pretrained_model_path
- EVAL.pretrained_model_path
- mode
- output_dir
- log_freq
sweep:
# output directory for multirun
dir: ${hydra.run.dir}
Expand Down
19 changes: 10 additions & 9 deletions examples/phylstm/conf/phylstm3.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
defaults:
- ppsci_default
- TRAIN: train_default
- TRAIN/ema: ema_default
- TRAIN/swa: swa_default
- EVAL: eval_default
- INFER: infer_default
- hydra/job/config/override_dirname/exclude_keys: exclude_keys_default
- _self_

hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_PhyLSTM3/${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
config:
override_dirname:
exclude_keys:
- TRAIN.checkpoint_path
- TRAIN.pretrained_model_path
- EVAL.pretrained_model_path
- mode
- output_dir
- log_freq
sweep:
# output directory for multirun
dir: ${hydra.run.dir}
Expand Down
2 changes: 1 addition & 1 deletion ppsci/solver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def dist_wrapper(model: nn.Layer) -> paddle.DataParallel:
if version.Version(paddle.__version__) < version.Version("2.6.0"):
logger.warning(
f"Detected paddlepaddle version is '{paddle_version}', "
"currently it is recommended to use release 2.6 or develop version."
"currently it is recommended to use paddlepaddle >= 2.6 or develop version."
)
else:
paddle_version = f"develop({paddle.version.commit[:7]})"
Expand Down