Skip to content

Commit

Permalink
fix ql scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
iProzd committed May 15, 2024
1 parent 9242bac commit bdb1648
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
4 changes: 3 additions & 1 deletion deepmd/dpmodel/utils/type_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
self.padding = padding
self.use_econf_tebd = use_econf_tebd
self.type_map = type_map
embed_input_dim = ntypes
if self.use_econf_tebd:
from deepmd.utils.econf_embd import (
ECONF_DIM,
Expand All @@ -87,8 +88,9 @@ def __init__(
[electronic_configuration_embedding[kk] for kk in self.type_map],
dtype=PRECISION_DICT[self.precision],
)
embed_input_dim = ECONF_DIM
self.embedding_net = EmbeddingNet(
ECONF_DIM if self.use_econf_tebd else ntypes,
embed_input_dim,
self.neuron,
self.activation_function,
self.resnet_dt,
Expand Down
26 changes: 10 additions & 16 deletions deepmd/pt/model/network/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ def __init__(
self.use_econf_tebd = use_econf_tebd
self.type_map = type_map
self.econf_tebd = None
embed_input_dim = ntypes
if self.use_econf_tebd:
from deepmd.utils.econf_embd import (
ECONF_DIM,
Expand All @@ -693,22 +694,15 @@ def __init__(
dtype=PRECISION_DICT[self.precision],
)
)
self.embedding_net = EmbeddingNet(
ECONF_DIM,
self.neuron,
self.activation_function,
self.resnet_dt,
self.precision,
)
else:
# no way to pass seed?
self.embedding_net = EmbeddingNet(
ntypes,
self.neuron,
self.activation_function,
self.resnet_dt,
self.precision,
)
embed_input_dim = ECONF_DIM
# no way to pass seed?
self.embedding_net = EmbeddingNet(
embed_input_dim,
self.neuron,
self.activation_function,
self.resnet_dt,
self.precision,
)
for param in self.parameters():
param.requires_grad = trainable

Expand Down
26 changes: 10 additions & 16 deletions deepmd/tf/utils/type_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,20 @@ def serialize(self, suffix: str = "") -> dict:
else:
type_embedding_pattern = TYPE_EMBEDDING_PATTERN
assert self.type_embedding_net_variables is not None
if not self.use_econf_tebd:
embedding_net = EmbeddingNet(
in_dim=self.ntypes,
neuron=self.neuron,
activation_function=self.filter_activation_fn_name,
resnet_dt=self.filter_resnet_dt,
precision=self.filter_precision.name,
)
else:
embed_input_dim = self.ntypes
if self.use_econf_tebd:
from deepmd.utils.econf_embd import (
ECONF_DIM,
)

embedding_net = EmbeddingNet(
in_dim=ECONF_DIM,
neuron=self.neuron,
activation_function=self.filter_activation_fn_name,
resnet_dt=self.filter_resnet_dt,
precision=self.filter_precision.name,
)
embed_input_dim = ECONF_DIM
embedding_net = EmbeddingNet(
in_dim=embed_input_dim,
neuron=self.neuron,
activation_function=self.filter_activation_fn_name,
resnet_dt=self.filter_resnet_dt,
precision=self.filter_precision.name,
)
for key, value in self.type_embedding_net_variables.items():
m = re.search(type_embedding_pattern, key)
m = [mm for mm in m.groups() if mm is not None]
Expand Down
2 changes: 1 addition & 1 deletion deepmd/utils/econf_embd.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@
maxn = 7
maxl = maxn
maxm = 2 * maxl + 1
ECONF_DIM = 59

type_map = dpdata.periodic_table.ELEMENTS
ECONF_DIM = electronic_configuration_embedding[type_map[0]].shape[0]


def make_empty_list_vec():
Expand Down

0 comments on commit bdb1648

Please sign in to comment.