keras-team/keras · error · ValueError
If imagenet weights are being loaded, alpha must be one of `
Error message
If imagenet weights are being loaded, alpha must be one of `0.35`, `0.50`, `0.75`, `1.0`, `1.3` or `1.4` only; Received `alpha={alpha}` What it means
Error "If imagenet weights are being loaded, alpha must be one of `0.35`, `0.50`, `0.75`, `1.0`, `1.3` or `1.4` only; Received `alpha={alpha}`" thrown in keras-team/keras.
Source
Thrown at keras/src/applications/mobilenet_v2.py:228
input_shape = imagenet_utils.obtain_input_shape(
input_shape,
default_size=default_size,
min_size=32,
data_format=backend.image_data_format(),
require_flatten=include_top,
weights=weights,
)
if backend.image_data_format() == "channels_last":
row_axis, col_axis = (0, 1)
else:
row_axis, col_axis = (1, 2)
rows = input_shape[row_axis]
cols = input_shape[col_axis]
if weights == "imagenet":
if alpha not in [0.35, 0.50, 0.75, 1.0, 1.3, 1.4]:
raise ValueError(
"If imagenet weights are being loaded, "
"alpha must be one of `0.35`, `0.50`, `0.75`, "
"`1.0`, `1.3` or `1.4` only;"
f" Received `alpha={alpha}`"
)
if rows != cols or rows not in [96, 128, 160, 192, 224]:
rows = 224
warnings.warn(
"`input_shape` is undefined or non-square, "
"or `rows` is not in [96, 128, 160, 192, 224]. "
"Weights for input shape (224, 224) will be "
"loaded as the default.",
stacklevel=2,
)
if input_tensor is None:
img_input = layers.Input(shape=input_shape)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/applications/mobilenet_v2.py:228 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/cfa0454be1a37b78.
Report an issue: GitHub.