keras-team/keras · error · ValueError
Shapes used to initialize variables must be fully-defined (n
Error message
Shapes used to initialize variables must be fully-defined (no `None` dimensions). Received: shape={shape} for variable path='{self.path}' What it means
Error "Shapes used to initialize variables must be fully-defined (no `None` dimensions). Received: shape={shape} for variable path='{self.path}'" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/common/variables.py:238
# returns early and does not raise an error.
if config.is_nnx_enabled():
return
raise ValueError(f"Variable {self.path} is already initialized.")
if in_stateless_scope():
raise ValueError(
"You are attempting to initialize a variable "
"while in a stateless scope. This is disallowed. "
"Make sure that all variables are initialized "
"before you start using your layer/model objects."
)
self._initialize_with_initializer(self._initializer)
self._initializer = None
def _validate_shape(self, shape):
shape = standardize_shape(shape)
if None in shape:
raise ValueError(
"Shapes used to initialize variables must be "
"fully-defined (no `None` dimensions). Received: "
f"shape={shape} for variable path='{self.path}'"
)
return shape
def _maybe_autocast(self, value):
autocast_scope = get_autocast_scope()
if self._autocast and autocast_scope is not None:
return autocast_scope.maybe_cast(value)
return value
def numpy(self):
return np.array(self)
@property
def aggregation(self):
"""The strategy for aggregating this variable."""View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/common/variables.py:238 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/e94173820acca752.
Report an issue: GitHub.