{"record":{"id":"f206146c4f705ef1","repo":"keras-team/keras","slug":"mask-t-is-expected-to-be-tensor-but-got-mask-t","errorCode":null,"errorMessage":"mask_t is expected to be tensor, but got {mask_t}","messagePattern":"mask_t is expected to be tensor, but got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/legacy/backend.py","lineNumber":1473,"sourceCode":"        if mask.dtype != tf.bool:\n            mask = tf.cast(mask, tf.bool)\n        if len(mask.shape) == 2:\n            mask = expand_dims(mask)\n        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 = []","sourceCodeStart":1455,"sourceCodeEnd":1491,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/legacy/backend.py#L1455-L1491","documentation":"Error \"mask_t is expected to be tensor, but got {mask_t}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/legacy/backend.py:1473 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"}