Skip to content

Commit

Permalink
throw error if both are provided
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Nov 13, 2024
1 parent 4939e1e commit f6538a7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions deepmd/tf/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,11 @@ def deserialize(cls, data: dict, suffix: str = "") -> "Descriptor":
-------
Descriptor
The deserialized descriptor
Raises
------
ValueError
If both fitting/@variables/bias_atom_e and @variables/out_bias are non-zero
"""
data = data.copy()
check_version_compatibility(data.pop("@version", 2), 2, 1)
Expand All @@ -815,6 +820,14 @@ def deserialize(cls, data: dict, suffix: str = "") -> "Descriptor":
# deepcopy is not used for performance reasons
data["fitting"] = data["fitting"].copy()
data["fitting"]["@variables"] = data["fitting"]["@variables"].copy()
if (
int(np.any(data["fitting"]["@variables"]["bias_atom_e"]))
+ int(np.any(data["@variables"]["out_bias"]))
> 1
):
raise ValueError(
"fitting/@variables/bias_atom_e and @variables/out_bias should not be both non-zero"
)
data["fitting"]["@variables"]["bias_atom_e"] = data["fitting"][
"@variables"
]["bias_atom_e"] + data["@variables"]["out_bias"].reshape(
Expand Down

0 comments on commit f6538a7

Please sign in to comment.