keras-team/keras · error · ValueError
The `weights` argument should be either `None` (random initi
Error message
The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded. Received weights={weights} What it means
Error "The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded. Received weights={weights}" thrown in keras-team/keras.
Source
Thrown at keras/src/applications/mobilenet_v3.py:171
def MobileNetV3(
stack_fn,
last_point_ch,
input_shape=None,
alpha=1.0,
model_type="large",
minimalistic=False,
include_top=True,
weights="imagenet",
input_tensor=None,
classes=1000,
pooling=None,
dropout_rate=0.2,
classifier_activation="softmax",
include_preprocessing=True,
name=None,
):
if not (weights in {"imagenet", None} or file_utils.exists(weights)):
raise ValueError(
"The `weights` argument should be either "
"`None` (random initialization), `imagenet` "
"(pre-training on ImageNet), "
"or the path to the weights file to be loaded. "
f"Received weights={weights}"
)
if weights == "imagenet" and include_top and classes != 1000:
raise ValueError(
'If using `weights="imagenet"` with `include_top` '
"as true, `classes` should be 1000. "
f"Received classes={classes}"
)
# Determine proper input shape and default size.
# If both input_shape and input_tensor are used, they should match
if input_shape is not None and input_tensor is not None:
try:View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/applications/mobilenet_v3.py:171 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/0a4e1ec1e15f5db8.
Report an issue: GitHub.