{"record":{"id":"2bd8b8a8831bd664","repo":"keras-team/keras","slug":"input-t-is-expected-to-be-tensor-but-got-input-t","errorCode":null,"errorMessage":"input_t is expected to be tensor, but got {input_t}","messagePattern":"input_t is expected to be tensor, but got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/legacy/backend.py","lineNumber":1477,"sourceCode":"        if not time_major:\n            mask = swap_batch_timestep(mask)\n\n    if constants is None:\n        constants = []\n\n    # tf.where needs its condition tensor to be the same shape as its two\n    # result tensors, but in our case the condition (mask) tensor is\n    # (nsamples, 1), and inputs are (nsamples, ndimensions) or even more.\n    # So we need to broadcast the mask to match the shape of inputs.\n    # That's what the tile call does, it just repeats the mask along its\n    # second dimension n times.\n    def _expand_mask(mask_t, input_t, fixed_dim=1):\n        if tf.nest.is_nested(mask_t):\n            raise ValueError(\n                f\"mask_t is expected to be tensor, but got {mask_t}\"\n            )\n        if tf.nest.is_nested(input_t):\n            raise ValueError(\n                f\"input_t is expected to be tensor, but got {input_t}\"\n            )\n        rank_diff = len(input_t.shape) - len(mask_t.shape)\n        for _ in range(rank_diff):\n            mask_t = tf.expand_dims(mask_t, -1)\n        multiples = [1] * fixed_dim + input_t.shape.as_list()[fixed_dim:]\n        return tf.tile(mask_t, multiples)\n\n    if unroll:\n        if not time_steps:\n            raise ValueError(\"Unrolling requires a fixed number of timesteps.\")\n        states = tuple(initial_states)\n        successive_states = []\n        successive_outputs = []\n\n        # Process the input tensors. The input tensor need to be split on the\n        # time_step dim, and reverse if go_backwards is True. In the case of\n        # nested input, the input is flattened and then transformed","sourceCodeStart":1459,"sourceCodeEnd":1495,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/legacy/backend.py#L1459-L1495","documentation":"Error \"input_t is expected to be tensor, but got {input_t}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/legacy/backend.py:1477 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"}