{"record":{"id":"e93cb3c58742d800","repo":"keras-team/keras","slug":"cannot-apply-softmax-to-a-tensor-that-is-1d-recei","errorCode":null,"errorMessage":"Cannot apply softmax to a tensor that is 1D. Received input: {x}","messagePattern":"Cannot apply softmax to a tensor that is 1D\\. Received input: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/legacy/backend.py","lineNumber":1910,"sourceCode":"\n\n@keras_export(\"keras._legacy.backend.sign\")\ndef sign(x):\n    \"\"\"DEPRECATED.\"\"\"\n    return tf.sign(x)\n\n\n@keras_export(\"keras._legacy.backend.sin\")\ndef sin(x):\n    \"\"\"DEPRECATED.\"\"\"\n    return tf.sin(x)\n\n\n@keras_export(\"keras._legacy.backend.softmax\")\ndef softmax(x, axis=-1):\n    \"\"\"DEPRECATED.\"\"\"\n    if x.shape.rank <= 1:\n        raise ValueError(\n            f\"Cannot apply softmax to a tensor that is 1D. Received input: {x}\"\n        )\n\n    if isinstance(axis, int):\n        output = tf.nn.softmax(x, axis=axis)\n    else:\n        # nn.softmax does not support tuple axis.\n        numerator = tf.exp(x - tf.reduce_max(x, axis=axis, keepdims=True))\n        denominator = tf.reduce_sum(numerator, axis=axis, keepdims=True)\n        output = numerator / denominator\n\n    # Cache the logits to use for crossentropy loss.\n    output._keras_logits = x\n    return output\n\n\n@keras_export(\"keras._legacy.backend.softplus\")\ndef softplus(x):","sourceCodeStart":1892,"sourceCodeEnd":1928,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/legacy/backend.py#L1892-L1928","documentation":"Error \"Cannot apply softmax to a tensor that is 1D. Received input: {x}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/legacy/backend.py:1910 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"}