keras-team/keras · error · ValueError
output_size must be an integer.
Error message
output_size must be an integer.
What it means
Error "output_size must be an integer." thrown in keras-team/keras.
Source
Thrown at keras/src/layers/rnn/rnn.py:248
else:
self.state_size = list(state_size)
self.single_state = False
def compute_output_shape(self, sequences_shape, initial_state_shape=None):
batch_size = sequences_shape[0]
length = sequences_shape[1]
states_shape = []
for state_size in self.state_size:
if isinstance(state_size, int):
states_shape.append((batch_size, state_size))
elif isinstance(state_size, (list, tuple)):
states_shape.append([(batch_size, s) for s in state_size])
output_size = getattr(self.cell, "output_size", None)
if output_size is None:
output_size = self.state_size[0]
if not isinstance(output_size, int):
raise ValueError("output_size must be an integer.")
if self.return_sequences:
output_shape = (batch_size, length, output_size)
else:
output_shape = (batch_size, output_size)
if self.return_state:
return output_shape, *states_shape
return output_shape
def compute_mask(self, _, mask):
# Time step masks must be the same for each input.
# This is because the mask for an RNN is of size [batch, time_steps, 1],
# and specifies which time steps should be skipped, and a time step
# must be skipped for all inputs.
mask = tree.flatten(mask)[0]
output_mask = mask if self.return_sequences else None
if self.return_state:
state_mask = [None for _ in self.state_size]
return [output_mask] + state_maskView on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/rnn/rnn.py:248 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/27bf7c687baf278c.
Report an issue: GitHub.