keras-team/keras · error · ValueError
`shift` and `axis` must be broadcastable to the same length.
Error message
`shift` and `axis` must be broadcastable to the same length. Received: shift={shift}, axis={axis} What it means
Error "`shift` and `axis` must be broadcastable to the same length. Received: shift={shift}, axis={axis}" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/common/backend_utils.py:454
return (value,)
return value
def normalize_shift_and_axis(shift, axis):
"""Normalize `shift` and `axis` arguments of `roll` to the same length.
Mirrors numpy's behavior of broadcasting a scalar (or length-1
sequence) `shift`/`axis` against the other argument. Accepts ints,
lists, tuples, and array-likes (e.g. numpy arrays).
"""
shifts = list(to_tuple_or_list(shift))
axes = list(to_tuple_or_list(axis))
if len(shifts) == 1:
shifts = shifts * len(axes)
if len(axes) == 1:
axes = axes * len(shifts)
if len(shifts) != len(axes):
raise ValueError(
"`shift` and `axis` must be broadcastable to the same length. "
f"Received: shift={shift}, axis={axis}"
)
return shifts, axes
### Code for ops.vectorize() used for TF and torch backends.
# See http://docs.scipy.org/doc/numpy/reference/c-api.generalized-ufuncs.html
_DIMENSION_NAME = r"\w+"
_CORE_DIMENSION_LIST = "(?:{0:}(?:,{0:})*)?".format(_DIMENSION_NAME)
_ARGUMENT = rf"\({_CORE_DIMENSION_LIST}\)"
_ARGUMENT_LIST = "{0:}(?:,{0:})*".format(_ARGUMENT)
_SIGNATURE = "^{0:}->{0:}$".format(_ARGUMENT_LIST)
def _vectorize_parse_gufunc_signature(
signature,View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/common/backend_utils.py:454 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/4833b3508f646617.
Report an issue: GitHub.