-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #4019. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced a `show` command to display model attributes via the command line. - Added a method to retrieve the model definition script for enhanced model access and usability. - Enhanced model configuration options in YAML files, allowing for detailed specifications of architecture and training parameters. - **Bug Fixes** - Simplified help messages for the `show` command, improving user clarity. - **Tests** - Added new tests to validate the retrieval of model definition scripts, ensuring accuracy in model configurations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
- Loading branch information
Showing
13 changed files
with
203 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
import logging | ||
from typing import ( | ||
List, | ||
) | ||
|
||
from deepmd.infer.deep_eval import ( | ||
DeepEval, | ||
) | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def show( | ||
*, | ||
INPUT: str, | ||
ATTRIBUTES: List[str], | ||
**kwargs, | ||
): | ||
model = DeepEval(INPUT, head=0) | ||
model_params = model.get_model_def_script() | ||
model_is_multi_task = "model_dict" in model_params | ||
log.info("This is a multitask model") if model_is_multi_task else log.info( | ||
"This is a singletask model" | ||
) | ||
|
||
if "model-branch" in ATTRIBUTES: | ||
# The model must be multitask mode | ||
if not model_is_multi_task: | ||
raise RuntimeError( | ||
"The 'model-branch' option requires a multitask model." | ||
" The provided model does not meet this criterion." | ||
) | ||
model_branches = list(model_params["model_dict"].keys()) | ||
model_branches += ["RANDOM"] | ||
log.info( | ||
f"Available model branches are {model_branches}, " | ||
f"where 'RANDOM' means using a randomly initialized fitting net." | ||
) | ||
if "type-map" in ATTRIBUTES: | ||
if model_is_multi_task: | ||
model_branches = list(model_params["model_dict"].keys()) | ||
for branch in model_branches: | ||
type_map = model_params["model_dict"][branch]["type_map"] | ||
log.info(f"The type_map of branch {branch} is {type_map}") | ||
else: | ||
type_map = model_params["type_map"] | ||
log.info(f"The type_map is {type_map}") | ||
if "descriptor" in ATTRIBUTES: | ||
if model_is_multi_task: | ||
model_branches = list(model_params["model_dict"].keys()) | ||
for branch in model_branches: | ||
descriptor = model_params["model_dict"][branch]["descriptor"] | ||
log.info(f"The descriptor parameter of branch {branch} is {descriptor}") | ||
else: | ||
descriptor = model_params["descriptor"] | ||
log.info(f"The descriptor parameter is {descriptor}") | ||
if "fitting-net" in ATTRIBUTES: | ||
if model_is_multi_task: | ||
model_branches = list(model_params["model_dict"].keys()) | ||
for branch in model_branches: | ||
fitting_net = model_params["model_dict"][branch]["fitting_net"] | ||
log.info( | ||
f"The fitting_net parameter of branch {branch} is {fitting_net}" | ||
) | ||
else: | ||
fitting_net = model_params["fitting_net"] | ||
log.info(f"The fitting_net parameter is {fitting_net}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.