keras-team/keras · error · ValueError
`unroll` must be an positive integer or boolean. Received: u
Error message
`unroll` must be an positive integer or boolean. Received: unroll={unroll} What it means
Error "`unroll` must be an positive integer or boolean. Received: unroll={unroll}" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/tensorflow/core.py:290
return tree.map_structure(tf.TensorSpec.from_tensor, out)
if tree.is_nested(xs):
input = tree.pack_sequence_as(xs, [x[0] for x in tree.flatten(xs)])
fn_output_signature = get_fn_output_signature(input)
return tf.map_fn(f, xs, fn_output_signature=fn_output_signature)
else:
fn_output_signature = get_fn_output_signature(xs[0])
return tf.map_fn(f, xs, fn_output_signature=fn_output_signature)
def scan(f, init, xs=None, length=None, reverse=False, unroll=1):
# We have reimplemented `scan` to match the behavior of `jax.lax.scan`
# Ref: tf.scan, jax.lax.scan
if not callable(f):
raise TypeError(f"`f` should be a callable. Received: f={f}")
if not isinstance(unroll, bool):
if not isinstance(unroll, int) or unroll < 1:
raise ValueError(
"`unroll` must be an positive integer or boolean. "
f"Received: unroll={unroll}"
)
if xs is None and length is None:
raise ValueError("Got no `xs` to scan over and `length` not provided.")
input_is_sequence = tree.is_nested(xs)
output_is_sequence = tree.is_nested(init)
def pack_input(x):
return tree.pack_sequence_as(xs, x) if input_is_sequence else x[0]
def pack_output(x):
return tree.pack_sequence_as(init, x) if output_is_sequence else x[0]
if xs is None:
xs_flat = []
n = int(length)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/tensorflow/core.py:290 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/ad47f7adfc7574f1.
Report an issue: GitHub.