{"record":{"id":"c13b6c41715bbd36","repo":"keras-team/keras","slug":"unrolling-requires-a-fixed-number-of-timesteps","errorCode":null,"errorMessage":"Unrolling requires a fixed number of timesteps.","messagePattern":"Unrolling requires a fixed number of timesteps\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/legacy/backend.py","lineNumber":1488,"sourceCode":"    # 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\n        # individually.  The result of this will be a tuple of lists, each of\n        # the item in tuple is list of the tensor with shape (batch, feature)\n        def _process_single_input_t(input_t):\n            input_t = tf.unstack(input_t)  # unstack for time_step dim\n            if go_backwards:\n                input_t.reverse()\n            return input_t\n\n        if tf.nest.is_nested(inputs):\n            processed_input = tf.nest.map_structure(\n                _process_single_input_t, inputs","sourceCodeStart":1470,"sourceCodeEnd":1506,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/legacy/backend.py#L1470-L1506","documentation":"Error \"Unrolling requires a fixed number of timesteps.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/legacy/backend.py:1488 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"}