{"record":{"id":"c824573588c2d410","repo":"keras-team/keras","slug":"the-rnn-cell-should-have-a-state-size-attribute","errorCode":null,"errorMessage":"The RNN cell should have a `state_size` attribute (single integer or list of integers, one integer per RNN state). Received: cell={cell}","messagePattern":"The RNN cell should have a `state_size` attribute \\(single integer or list of integers, one integer per RNN state\\)\\. Received: cell=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/rnn/rnn.py","lineNumber":193,"sourceCode":"        self,\n        cell,\n        return_sequences=False,\n        return_state=False,\n        go_backwards=False,\n        stateful=False,\n        unroll=False,\n        zero_output_for_mask=False,\n        **kwargs,\n    ):\n        if isinstance(cell, (list, tuple)):\n            cell = StackedRNNCells(cell)\n        if \"call\" not in dir(cell):\n            raise ValueError(\n                \"Argument `cell` should have a `call` method. \"\n                f\"Received: cell={cell}\"\n            )\n        if \"state_size\" not in dir(cell):\n            raise ValueError(\n                \"The RNN cell should have a `state_size` attribute \"\n                \"(single integer or list of integers, \"\n                \"one integer per RNN state). \"\n                f\"Received: cell={cell}\"\n            )\n        super().__init__(**kwargs)\n\n        # If True, the output for masked timestep will be zeros, whereas in the\n        # False case, output from previous timestep is returned for masked\n        # timestep.\n        self.zero_output_for_mask = zero_output_for_mask\n        self.cell = cell\n        self.return_sequences = return_sequences\n        self.return_state = return_state\n        self.go_backwards = go_backwards\n        self.stateful = stateful\n        self.unroll = unroll\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/rnn/rnn.py#L175-L211","documentation":"Error \"The RNN cell should have a `state_size` attribute (single integer or list of integers, one integer per RNN state). Received: cell={cell}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/rnn/rnn.py:193 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"}