From e033f4f154ea568c735cd9685456230965dfeb77 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 20 Jan 2025 17:28:34 +0800 Subject: [PATCH] fix: fix YAML conversion Fix #4564. Signed-off-by: Jinzhe Zeng --- deepmd/dpmodel/utils/serialization.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deepmd/dpmodel/utils/serialization.py b/deepmd/dpmodel/utils/serialization.py index 1c07038a23..5520933753 100644 --- a/deepmd/dpmodel/utils/serialization.py +++ b/deepmd/dpmodel/utils/serialization.py @@ -113,7 +113,9 @@ def save_dp_model(filename: str, model_dict: dict) -> None: "@version": 1, "dtype": x.dtype.name, "value": x.tolist(), - }, + } + if isinstance(x, np.ndarray) + else x, ) with open(filename, "w") as f: yaml.safe_dump(