deepmodeling / deepmd-kit

A deep learning package for many-body potential energy representation and molecular dynamics
https://docs.deepmodeling.com/projects/deepmd/
GNU Lesser General Public License v3.0
1.41k stars 486 forks source link

Bug: Error when loading a model with the se_a_mask descriptor #3928

Closed wanghan-iapcm closed 2 days ago

wanghan-iapcm commented 5 days ago

Discussed in https://github.com/deepmodeling/deepmd-kit/discussions/3924

Originally posted by **lukasbaldauf** June 28, 2024 Hi All, I want to evaluate a trained model using the `se_a_mask` descriptor, but I'm encountering an error. The training goes smoothly and I get good accuracies for my system, I'm just having trouble loading the model. I get the same error when evaluating the trained zinc_protein example system (see the error message below). It seems like something related to "dfparam" and "daparam", where the Tensors are missing. I get the same errors for deepmd versions 2.2.7 and 2.2.10, and tensorflow versions 2.9.0 and 2.15.0. For the zinc example, I train and freeze the model as such: ```shell dp train zinc_se_a_mask.json --skip-neighbor-stat dp freeze -o graph.mask.pb ``` The problem occurs when I want to load the model: ```python from deepmd.infer import DeepPot model = DeepPot("graph.mask.pb") ``` --- Traceback (most recent call last): File "", line 1, in File "/home/lukasb/miniforge3/envs/deepmd_gpu_2.2.7/lib/python3.10/site-packages/deepmd/infer/deep_pot.py", line 156, in __init__ self._get_tensor(tensor_name, attr_name) File "/home/lukasb/miniforge3/envs/deepmd_gpu_2.2.7/lib/python3.10/site-packages/deepmd/infer/deep_eval.py", line 165, in _get_tensor tensor = self.graph.get_tensor_by_name(tensor_path) File "/home/lukasb/miniforge3/envs/deepmd_gpu_2.2.7/lib/python3.10/site-packages/tensorflow/python/framework/ops.py", line 4128, in get_tensor_by_name return self.as_graph_element(name, allow_tensor=True, allow_operation=False) File "/home/lukasb/miniforge3/envs/deepmd_gpu_2.2.7/lib/python3.10/site-packages/tensorflow/python/framework/ops.py", line 3952, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/home/lukasb/miniforge3/envs/deepmd_gpu_2.2.7/lib/python3.10/site-packages/tensorflow/python/framework/ops.py", line 3992, in _as_graph_element_locked raise KeyError("The name %s refers to a Tensor which does not " KeyError: "The name 'load/fitting_attr/dfparam:0' refers to a Tensor which does not exist. The operation, 'load/fitting_attr/dfparam', does not exist in the graph."
njzjz commented 5 days ago

Reproduced in v2.2.10 but failed to reproduce in devel.