{"record":{"id":"39399f4b88db584f","repo":"keras-team/keras","slug":"all-tensors-passed-to-ops-shape-must-have-a-stat","errorCode":null,"errorMessage":"All tensors passed to `ops.shape` must have a statically known rank. Received: x={x} with unknown rank.","messagePattern":"All tensors passed to `ops\\.shape` must have a statically known rank\\. Received: x=(.+?) with unknown rank\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/tensorflow/core.py","lineNumber":194,"sourceCode":"def is_tensor(x):\n    return tf.is_tensor(x)\n\n\ndef shape(x):\n    \"\"\"Always return a tuple shape.\n\n    `tf.shape` will return a `tf.Tensor`, which differs from the tuple return\n    type on the torch and jax backends. We write our own method instead which\n    always returns a tuple, with integer values when the shape is known, and\n    tensor values when the shape is unknown (this is tf specific, as dynamic\n    shapes do not apply in other backends).\n    \"\"\"\n    if isinstance(x, KerasTensor):\n        return x.shape\n    if not tf.is_tensor(x):\n        x = tf.convert_to_tensor(x)\n    if x.shape == tf.TensorShape(None):\n        raise ValueError(\n            \"All tensors passed to `ops.shape` must have a statically known \"\n            f\"rank. Received: x={x} with unknown rank.\"\n        )\n    shape = x.shape.as_list()\n    dynamic = tf.shape(x)\n    for i in range(len(shape)):\n        if shape[i] is None:\n            try:\n                shape[i] = dynamic[i]\n            except:\n                # With RaggedTensors, accessing a ragged dimension will fail,\n                # we leave it as None.\n                pass\n    return tuple(shape)\n\n\ndef cast(x, dtype):\n    dtype = standardize_dtype(dtype)","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/tensorflow/core.py#L176-L212","documentation":"Error \"All tensors passed to `ops.shape` must have a statically known rank. Received: x={x} with unknown rank.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/tensorflow/core.py:194 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}