{"record":{"id":"f068f7a276cc9186","repo":"keras-team/keras","slug":"state-size-must-be-specified-as-property-on-the-rn","errorCode":null,"errorMessage":"state_size must be specified as property on the RNN cell.","messagePattern":"state_size must be specified as property on the RNN cell\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/rnn/rnn.py","lineNumber":219,"sourceCode":"        # 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\n        self.supports_masking = False\n        self.input_spec = None\n        self.states = None\n        self._expected_batch_size = None\n\n        state_size = getattr(self.cell, \"state_size\", None)\n        if state_size is None:\n            raise ValueError(\n                \"state_size must be specified as property on the RNN cell.\"\n            )\n        if not isinstance(state_size, (list, tuple, int)):\n            raise ValueError(\n                \"state_size must be an integer, or a list/tuple of integers \"\n                \"(one for each state tensor).\"\n            )\n        if isinstance(state_size, int):\n            self.state_size = [state_size]\n            self.single_state = True\n        else:\n            self.state_size = list(state_size)\n            self.single_state = False\n\n    def compute_output_shape(self, sequences_shape, initial_state_shape=None):\n        batch_size = sequences_shape[0]\n        length = sequences_shape[1]\n        states_shape = []","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/rnn/rnn.py#L201-L237","documentation":"Error \"state_size must be specified as property on the RNN cell.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/rnn/rnn.py:219 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"}