Skip to content

Commit

Permalink
fix(tf): prevent fitting_attr variable scope from becoming `fitting…
Browse files Browse the repository at this point in the history
…_attr_1` (deepmodeling#3930)

Fix deepmodeling#3928. Prevent `fitting_attr` from becoming `fitting_attr_1`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Improved TensorFlow variable scope management by switching to
`tf.AUTO_REUSE` to streamline code and reduce the likelihood of variable
reuse conflicts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz authored and Mathieu Taillefumier committed Sep 18, 2024
1 parent 3c94760 commit b4d7016
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions deepmd/tf/descriptor/se_a_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ def build(
aparam[:, :] is the real/virtual sign for each atom.
"""
aparam = input_dict["aparam"]
with tf.variable_scope("fitting_attr" + suffix, reuse=reuse):
t_aparam_nall = tf.constant(True, name="aparam_nall", dtype=tf.bool)
t_aparam_nall = tf.constant(
True, name=f"fitting_attr{suffix}/aparam_nall", dtype=tf.bool
)
self.mask = tf.cast(aparam, tf.int32)
self.mask = tf.reshape(self.mask, [-1, natoms[1]])

Expand Down

0 comments on commit b4d7016

Please sign in to comment.