{"record":{"id":"312520d77cfb70a2","repo":"keras-team/keras","slug":"sparse-true-is-not-supported-with-the-backend-b","errorCode":null,"errorMessage":"`sparse=True` is not supported with the {backend.backend()} backend","messagePattern":"`sparse=True` is not supported with the (.+?) backend","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/core/input_layer.py","lineNumber":99,"sourceCode":"                    \"same time.\"\n                )\n            if batch_size is not None and batch_shape is not None:\n                raise ValueError(\n                    \"You cannot pass both `batch_size` and `batch_shape` \"\n                    \"at the same time.\"\n                )\n            if shape is None and batch_shape is None:\n                raise ValueError(\"You must pass a `shape` argument.\")\n\n            if shape is not None:\n                shape = backend.standardize_shape(shape)\n                batch_shape = (batch_size,) + shape\n\n        self._batch_shape = backend.standardize_shape(batch_shape)\n        self._dtype = backend.standardize_dtype(dtype)\n        self.sparse = bool(sparse)\n        if self.sparse and not backend.SUPPORTS_SPARSE_TENSORS:\n            raise ValueError(\n                f\"`sparse=True` is not supported with the {backend.backend()} \"\n                \"backend\"\n            )\n        self.ragged = bool(ragged)\n        if self.ragged and not backend.SUPPORTS_RAGGED_TENSORS:\n            raise ValueError(\n                f\"`ragged=True` is not supported with the {backend.backend()} \"\n                \"backend\"\n            )\n\n        if input_tensor is None:\n            input_tensor = backend.KerasTensor(\n                shape=batch_shape,\n                dtype=dtype,\n                sparse=sparse,\n                ragged=ragged,\n                name=name,\n            )","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/core/input_layer.py#L81-L117","documentation":"Raised in InputLayer.__init__ after construction: the active backend (identified by backend.backend(), e.g. jax or numpy) does not set SUPPORTS_SPARSE_TENSORS, yet sparse=True was requested (or inherited from an input tensor). It is a capability guard, not a malformed-argument error.","triggerScenarios":"Thrown at keras/src/layers/core/input_layer.py:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Switch to a backend that supports sparse tensors such as TensorFlow","Set sparse=False and densify the data before feeding it to the model","Keep sparse tensors only in preprocessing and convert to dense for model input"],"exampleFix":null,"handlingStrategy":"fallback","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"}