keras-team/keras · error · ValueError
If imagenet weights are being loaded, alpha can be one…
Error message
If imagenet weights are being loaded, alpha can be one of`0.25`, `0.50`, `0.75` or `1.0` only. Received alpha={alpha} What it means
MobileNet builder in keras/src/applications/mobilenet.py: pretrained ImageNet checkpoints exist only for alpha (width multiplier) in {0.25, 0.5, 0.75, 1.0}. Any other alpha with weights='imagenet' would change every layer's filter count and break checkpoint loading, hence the guard.
Solutions
- Choose alpha from [0.25, 0.50, 0.75, 1.0] when loading ImageNet weights
- Use weights=None to train an arbitrary-width MobileNet from scratch
- Snap a custom alpha to the nearest supported value if pretrained performance suffices
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/applications/mobilenet.py:167 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/c506c230b7080c5c.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/applications/mobilenet.py:167
)
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 depth_multiplier != 1:
raise ValueError(
"If imagenet weights are being loaded, "
"depth multiplier must be 1. "
f"Received depth_multiplier={depth_multiplier}"
)
if alpha not in [0.25, 0.50, 0.75, 1.0]:
raise ValueError(
"If imagenet weights are being loaded, "
"alpha can be one of"
"`0.25`, `0.50`, `0.75` or `1.0` only. "
f"Received alpha={alpha}"
)
if rows != cols or rows not in [128, 160, 192, 224]:
rows = 224
warnings.warn(
"`input_shape` is undefined or non-square, "
"or `rows` is not in [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)