keras-team/keras · error · ValueError
Argument `constant_values` can only be provided when `mode =
Error message
Argument `constant_values` can only be provided when `mode == 'constant'`. Received: mode={mode} What it means
Error "Argument `constant_values` can only be provided when `mode == 'constant'`. Received: mode={mode}" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/numpy/numpy.py:1270
def ones_like(x, dtype=None):
return np.ones_like(x, dtype=dtype)
def outer(x1, x2):
x1 = convert_to_tensor(x1)
x2 = convert_to_tensor(x2)
dtype = dtypes.result_type(x1.dtype, x2.dtype)
x1 = x1.astype(dtype)
x2 = x2.astype(dtype)
return np.outer(x1, x2)
def pad(x, pad_width, mode="constant", constant_values=None):
kwargs = {}
if constant_values is not None:
if mode != "constant":
raise ValueError(
"Argument `constant_values` can only be "
"provided when `mode == 'constant'`. "
f"Received: mode={mode}"
)
kwargs["constant_values"] = constant_values
return np.pad(x, pad_width, mode=mode, **kwargs)
def percentile(x, q, axis=None, method="linear", keepdims=False):
x = convert_to_tensor(x)
q = convert_to_tensor(q)
ori_dtype = standardize_dtype(x.dtype)
if ori_dtype == "bool":
x = x.astype(config.floatx())
dtype = dtypes.result_type(x.dtype, float)
return np.percentile(
x, q, axis=axis, method=method, keepdims=keepdims
).astype(dtype)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/numpy/numpy.py:1270 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/fca270aa43064a1e.
Report an issue: GitHub.