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` (#3930)

Fix #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 <[email protected]>
(cherry picked from commit e809e64)
  • Loading branch information
njzjz committed Jul 3, 2024
1 parent 2b448cb commit 8b485a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions deepmd/descriptor/se_a_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,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 8b485a8

Please sign in to comment.