Skip to content

Commit

Permalink
change var_name to property_name
Browse files Browse the repository at this point in the history
  • Loading branch information
Chengqian-Zhang committed Dec 23, 2024
1 parent 28ef352 commit e74a6ac
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion deepmd/pt/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def model_type(self) -> type["DeepEvalWrapper"]:
return DeepGlobalPolar
elif "wfc" in model_output_type:
return DeepWFC
elif "property" in model_output_type:
elif self.dp.model["Default"].get_property_name() in model_output_type:
return DeepProperty
else:
raise RuntimeError("Unknown model type")
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/model/property_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_task_dim(self) -> int:
@torch.jit.export
def get_intensive(self) -> bool:
"""Get whether the property is intensive."""
return self.model_output_def()["property"].intensive
return self.model_output_def()[self.get_property_name()].intensive

@torch.jit.export
def get_property_name(self) -> str:
Expand Down
4 changes: 1 addition & 3 deletions deepmd/pt/model/task/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ def set_case_embd(self, case_idx: int):
]

def get_compute_stats_do_not_distinguish_types(self) -> bool:
"""
Get whether the fitting net computes stats which are not distinguished between different types of atoms.
"""
"""Get whether the fitting net computes stats which are not distinguished between different types of atoms."""
return False

def __setitem__(self, key, value) -> None:
Expand Down
4 changes: 1 addition & 3 deletions deepmd/pt/model/task/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ def output_def(self) -> FittingOutputDef:
)

def get_compute_stats_do_not_distinguish_types(self) -> bool:
"""
Get whether the fitting net computes stats which are not distinguished between different types of atoms.
"""
"""Get whether the fitting net computes stats which are not distinguished between different types of atoms."""
return True

@classmethod
Expand Down
20 changes: 12 additions & 8 deletions deepmd/utils/out_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,17 @@ def compute_stats_do_not_distinguish_types(
assert natoms.ndim == 2
assert output_redu.shape[0] == natoms.shape[0] # [nf,1]

computed_output_bias = np.repeat(
np.mean(output_redu, axis=0)[np.newaxis, :], ntypes, axis=0
)
output_std = np.std(output_redu, axis=0)

computed_output_bias = computed_output_bias.reshape([natoms.shape[1]] + var_shape) # noqa: RUF005
output_std = output_std.reshape(var_shape)
output_std = np.tile(output_std, (computed_output_bias.shape[0], 1))
if intensive:
computed_output_bias = np.repeat(
np.mean(output_redu, axis=0)[np.newaxis, :], ntypes, axis=0
)
output_std = np.std(output_redu, axis=0)

computed_output_bias = computed_output_bias.reshape([natoms.shape[1]] + var_shape) # noqa: RUF005
output_std = output_std.reshape(var_shape)
output_std = np.tile(output_std, (computed_output_bias.shape[0], 1))
else:
# TODO: implement extensive
pass

return computed_output_bias, output_std

0 comments on commit e74a6ac

Please sign in to comment.