Skip to content

Commit

Permalink
bug: fix numerical diff in DPA1 dotr between DP/PT (deepmodeling#3725)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved stability in calculations by handling potential division by
zero errors.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
iProzd authored and Mathieu Taillefumier committed Sep 18, 2024
1 parent 75df6a5 commit cc39eab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions deepmd/dpmodel/descriptor/dpa1.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ def call(

# calculate gg
gg = self.cal_g(ss, 0)
input_r = dmatrix.reshape(-1, nnei, 4)[:, :, 1:4] / (
input_r = dmatrix.reshape(-1, nnei, 4)[:, :, 1:4] / np.maximum(
np.linalg.norm(
dmatrix.reshape(-1, nnei, 4)[:, :, 1:4], axis=-1, keepdims=True
)
+ 1e-12
),
1e-12,
)
gg = self.dpa1_attention(
gg, nlist_mask, input_r=input_r, sw=sw
Expand Down

0 comments on commit cc39eab

Please sign in to comment.