{"record":{"id":"e94173820acca752","repo":"keras-team/keras","slug":"shapes-used-to-initialize-variables-must-be-fully","errorCode":null,"errorMessage":"Shapes used to initialize variables must be fully-defined (no `None` dimensions). Received: shape={shape} for variable path='{self.path}'","messagePattern":"Shapes used to initialize variables must be fully-defined \\(no `None` dimensions\\)\\. Received: shape=(.+?) for variable path='(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/common/variables.py","lineNumber":238,"sourceCode":"            # returns early and does not raise an error.\n            if config.is_nnx_enabled():\n                return\n            raise ValueError(f\"Variable {self.path} is already initialized.\")\n\n        if in_stateless_scope():\n            raise ValueError(\n                \"You are attempting to initialize a variable \"\n                \"while in a stateless scope. This is disallowed. \"\n                \"Make sure that all variables are initialized \"\n                \"before you start using your layer/model objects.\"\n            )\n        self._initialize_with_initializer(self._initializer)\n        self._initializer = None\n\n    def _validate_shape(self, shape):\n        shape = standardize_shape(shape)\n        if None in shape:\n            raise ValueError(\n                \"Shapes used to initialize variables must be \"\n                \"fully-defined (no `None` dimensions). Received: \"\n                f\"shape={shape} for variable path='{self.path}'\"\n            )\n        return shape\n\n    def _maybe_autocast(self, value):\n        autocast_scope = get_autocast_scope()\n        if self._autocast and autocast_scope is not None:\n            return autocast_scope.maybe_cast(value)\n        return value\n\n    def numpy(self):\n        return np.array(self)\n\n    @property\n    def aggregation(self):\n        \"\"\"The strategy for aggregating this variable.\"\"\"","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/common/variables.py#L220-L256","documentation":"Raised by Variable._validate_shape (called from __init__) when the shape passed to a Variable contains None dimensions. Initialization must allocate a concrete tensor via the initializer, and a None (dynamic) dimension makes exact allocation impossible, so variable shapes must be fully-defined.","triggerScenarios":"Thrown at keras/src/backend/common/variables.py:238 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply a fully-defined shape with concrete integer dimensions, e.g. (32, 10) instead of (None, 10).","Keep dynamic (None) dimensions on input tensors only, not on variable shapes.","If the shape comes from another tensor, materialize concrete dims first, e.g. via keras.ops.shape on a concrete value or after a real forward pass."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}