Skip to content

Commit

Permalink
modify laynorm
Browse files Browse the repository at this point in the history
  • Loading branch information
iProzd committed Jan 17, 2025
1 parent 1456920 commit 961fb76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions deepmd/pt/model/descriptor/repflow_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def __init__(
"const",
], "'update_residual_init' only support 'norm' or 'const'!"

if self.pre_ln:
assert self.update_style == "res_layer"
# if self.pre_ln:
# assert self.update_style == "res_layer"

if self.update_style == "res_layer":
if self.update_style == "res_layer" or self.pre_ln:
self.node_layernorm = nn.LayerNorm(
self.n_dim,
device=env.DEVICE,
Expand Down
22 changes: 11 additions & 11 deletions deepmd/pt/model/descriptor/repflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ def __init__(
self.epsilon = 1e-4
self.seed = seed
self.pre_ln = pre_ln
self.out_ln = None
if self.pre_ln:
self.out_ln = torch.nn.LayerNorm(
self.n_dim,
device=env.DEVICE,
dtype=self.prec,
elementwise_affine=False,
)
# self.out_ln = None
# if self.pre_ln:
# self.out_ln = torch.nn.LayerNorm(
# self.n_dim,
# device=env.DEVICE,
# dtype=self.prec,
# elementwise_affine=False,
# )

self.edge_embd = MLPLayer(
1, self.e_dim, precision=precision, seed=child_seed(seed, 0)
Expand Down Expand Up @@ -600,9 +600,9 @@ def forward(
h2g2 = RepFlowLayer._cal_hg(edge_ebd, h2, nlist_mask, sw)
# (nb x nloc) x e_dim x 3
rot_mat = torch.permute(h2g2, (0, 1, 3, 2))
if self.pre_ln:
assert self.out_ln is not None
node_ebd = self.out_ln(node_ebd)
# if self.pre_ln:
# assert self.out_ln is not None
# node_ebd = self.out_ln(node_ebd)

return node_ebd, edge_ebd, h2, rot_mat.view(nframes, nloc, self.dim_emb, 3), sw

Expand Down

0 comments on commit 961fb76

Please sign in to comment.