Skip to content

Commit 51aa455

Browse files
fix test
1 parent d18dd33 commit 51aa455

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

keras/src/backend/common/variables.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ def __init__(
211211

212212
def _deferred_initialize(self):
213213
if self._value is not None:
214+
# If NNX is enabled, it's possible the variable was already
215+
# initialized by a concrete call. In this case,
216+
# _deferred_initialize becomes a no-op for this variable.
217+
if config.is_nnx_enabled():
218+
self._initializer = None # Clear initializer as it's now "used"
219+
return
214220
raise ValueError(f"Variable {self.path} is already initialized.")
215221

216222
if in_stateless_scope():

0 commit comments

Comments
 (0)