Skip to content

Commit

Permalink
remove more annotations in code
Browse files Browse the repository at this point in the history
  • Loading branch information
HydrogenSulfate committed Dec 22, 2023
1 parent 52638f2 commit 5fa9d59
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 1,017 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
3. 安装 deepmd-kit

``` sh
git clone https://github.com/HydrogenSulfate/deepmd-kit.git -b add_ddle_backend
git clone https://github.com/deepmodeling/deepmd-kit.git -b paddle2
cd deepmd-kit
# 以 editable 的方式安装,方便调试
pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
Expand Down
19 changes: 9 additions & 10 deletions deepmd/descriptor/se_a.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __init__(
self.compress_activation_fn = get_activation_func(activation_function)
self.filter_activation_fn = get_activation_func(activation_function)
self.filter_precision = get_precision(precision)
self.exclude_types = set() # empty
self.exclude_types = set()
for tt in exclude_types:
assert len(tt) == 2
self.exclude_types.add((tt[0], tt[1]))
Expand Down Expand Up @@ -194,12 +194,12 @@ def __init__(
assert self.ntypes == len(self.sel_r)
self.rcut_a = -1
# numb of neighbors and numb of descrptors
self.nnei_a = np.cumsum(self.sel_a)[-1] # 138 邻域内原子个数
self.nnei_r = np.cumsum(self.sel_r)[-1] # 0
self.nnei = self.nnei_a + self.nnei_r # 138
self.ndescrpt_a = self.nnei_a * 4 # 552 原子个数*4([s, s/x, s/y, s/z])
self.ndescrpt_r = self.nnei_r * 1 # 0
self.ndescrpt = self.ndescrpt_a + self.ndescrpt_r # 552
self.nnei_a = np.cumsum(self.sel_a)[-1]
self.nnei_r = np.cumsum(self.sel_r)[-1]
self.nnei = self.nnei_a + self.nnei_r
self.ndescrpt_a = self.nnei_a * 4
self.ndescrpt_r = self.nnei_r * 1
self.ndescrpt = self.ndescrpt_a + self.ndescrpt_r
self.useBN = False
self.dstd = None
self.davg = None
Expand All @@ -215,7 +215,6 @@ def __init__(
[self.ntypes, self.ndescrpt], dtype=GLOBAL_PD_FLOAT_PRECISION
)
nets = []
# self._pass_filter => self._filter => self._filter_lower
for type_input in range(self.ntypes):
layer = []
for type_i in range(self.ntypes):
Expand Down Expand Up @@ -587,7 +586,7 @@ def forward(
suffix=suffix,
reuse=reuse,
trainable=self.trainable,
) # [1, all_atom, M1*M2], output_qmat: [1, all_atom, M1*3]
)

return self.dout

Expand Down Expand Up @@ -701,7 +700,7 @@ def _pass_filter(
reuse=reuse,
trainable=trainable,
activation_fn=self.filter_activation_fn,
) # [natom, M1*M2], qmat: [natom, M1, 3]
)
layer = paddle.reshape(
layer, [inputs.shape[0], natoms[2 + type_i], self.get_dim_out()]
)
Expand Down
3 changes: 1 addition & 2 deletions deepmd/entrypoints/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_ener(
data.add("energy", 1, atomic=False, must=False, high_prec=True)
data.add("force", 3, atomic=True, must=False, high_prec=False)
data.add("virial", 9, atomic=False, must=False, high_prec=False)
if dp.has_efield: # False
if dp.has_efield:
data.add("efield", 3, atomic=True, must=True, high_prec=False)
if has_atom_ener:
data.add("atom_ener", 1, atomic=True, must=True, high_prec=False)
Expand All @@ -278,7 +278,6 @@ def test_ener(
numb_test = min(nframes, numb_test)

coord = test_data["coord"][:numb_test].reshape([numb_test, -1])

box = test_data["box"][:numb_test]
if dp.has_efield:
efield = test_data["efield"][:numb_test].reshape([numb_test, -1])
Expand Down
7 changes: 3 additions & 4 deletions deepmd/entrypoints/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _do_work(jdata: Dict[str, Any], run_opt: RunOptions, is_compress: bool = Fal
dp_random.seed(seed)

# setup data modifier
modifier = get_modifier(jdata["model"].get("modifier", None)) # None
modifier = get_modifier(jdata["model"].get("modifier", None))

# check the multi-task mode
multi_task_mode = "fitting_net_dict" in jdata["model"]
Expand Down Expand Up @@ -275,7 +275,6 @@ def _do_work(jdata: Dict[str, Any], run_opt: RunOptions, is_compress: bool = Fal
origin_type_map = get_data(
jdata["training"]["training_data"], rcut, None, modifier
).get_type_map()
print("model.build")
model.build(train_data, stop_batch, origin_type_map=origin_type_map)

if not is_compress:
Expand Down Expand Up @@ -377,7 +376,7 @@ def get_nbor_stat(jdata, rcut, one_type: bool = False):
if type_map and len(type_map) == 0:
type_map = None
multi_task_mode = "data_dict" in jdata["training"]
if not multi_task_mode: # here
if not multi_task_mode:
train_data = get_data(
jdata["training"]["training_data"], max_rcut, type_map, None
)
Expand Down Expand Up @@ -496,7 +495,7 @@ def update_sel(jdata):
if descrpt_data["type"] == "hybrid":
for ii in range(len(descrpt_data["list"])):
descrpt_data["list"][ii] = update_one_sel(jdata, descrpt_data["list"][ii])
else: # here
else:
descrpt_data = update_one_sel(jdata, descrpt_data)
jdata["model"]["descriptor"] = descrpt_data
return jdata
2 changes: 1 addition & 1 deletion deepmd/fit/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def _build_lower(
if (not self.uniform_seed) and (self.seed is not None):
self.seed += self.seed_shift

return final_layer # [natoms, 1]
return final_layer

def forward(
self,
Expand Down
Loading

0 comments on commit 5fa9d59

Please sign in to comment.