{"record":{"id":"433fada3dcd871f9","repo":"keras-team/keras","slug":"a-kerastensor-is-symbolic-it-s-a-placeholder-for-433fad","errorCode":null,"errorMessage":"A KerasTensor is symbolic: it's a placeholder for a shape an a dtype. It doesn't have any actual numerical value. You cannot convert it to a NumPy array.","messagePattern":"A KerasTensor is symbolic: it's a placeholder for a shape an a dtype\\. It doesn't have any actual numerical value\\. You cannot convert it to a NumPy array\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/common/keras_tensor.py","lineNumber":164,"sourceCode":"\n        return ops.Squeeze(axis)(self)\n\n    def __int__(self):\n        raise ValueError(\n            \"A KerasTensor is symbolic: it's a placeholder for a shape \"\n            \"an a dtype. It doesn't have any actual numerical value. \"\n            \"You cannot convert it to an int.\"\n        )\n\n    def __float__(self):\n        raise ValueError(\n            \"A KerasTensor is symbolic: it's a placeholder for a shape \"\n            \"an a dtype. It doesn't have any actual numerical value. \"\n            \"You cannot convert it to a float.\"\n        )\n\n    def __array__(self):\n        raise ValueError(\n            \"A KerasTensor is symbolic: it's a placeholder for a shape \"\n            \"an a dtype. It doesn't have any actual numerical value. \"\n            \"You cannot convert it to a NumPy array.\"\n        )\n\n    def __jax_array__(self):\n        raise ValueError(\n            \"A KerasTensor cannot be used as input to a JAX function. \"\n            \"A KerasTensor is a symbolic placeholder for a shape and dtype, \"\n            \"used when constructing Keras Functional models \"\n            \"or Keras Functions. You can only use it as input to a Keras layer \"\n            \"or a Keras operation (from the namespaces `keras.layers` \"\n            \"and `keras.ops`). \"\n            \"You are likely doing something like:\\n\\n\"\n            \"```\\n\"\n            \"x = Input(...)\\n\"\n            \"...\\n\"\n            \"jax_fn(x)  # Invalid.\\n\"","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/common/keras_tensor.py#L146-L182","documentation":"Raised from KerasTensor.__array__ when NumPy tries to materialize a KerasTensor as an array (np.array(x), x.numpy()-style calls, NumPy APIs taking it as input). Since the tensor is a symbolic placeholder without values, array conversion is impossible and this protocol method makes the failure explicit rather than silently producing garbage.","triggerScenarios":"Thrown at keras/src/backend/common/keras_tensor.py:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call the model/function on actual data and convert the returned backend tensor with np.array","Use the concrete input or output values instead of the symbolic KerasTensor"],"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"}