keras-team/keras · error · ValueError
ImageNet weights can only be loaded with NASNetLarge or NASN
Error message
ImageNet weights can only be loaded with NASNetLarge or NASNetMobile
What it means
Error "ImageNet weights can only be loaded with NASNetLarge or NASNetMobile" thrown in keras-team/keras.
Source
Thrown at keras/src/applications/nasnet.py:304
model.load_weights(weights_path)
elif default_size == 331: # large version
if include_top:
weights_path = file_utils.get_file(
"nasnet_large.h5",
NASNET_LARGE_WEIGHT_PATH,
cache_subdir="models",
file_hash="11577c9a518f0070763c2b964a382f17",
)
else:
weights_path = file_utils.get_file(
"nasnet_large_no_top.h5",
NASNET_LARGE_WEIGHT_PATH_NO_TOP,
cache_subdir="models",
file_hash="d81d89dc07e6e56530c4e77faddd61b5",
)
model.load_weights(weights_path)
else:
raise ValueError(
"ImageNet weights can only be loaded with NASNetLarge"
" or NASNetMobile"
)
elif weights is not None:
model.load_weights(weights)
return model
@keras_export(
[
"keras.applications.nasnet.NASNetMobile",
"keras.applications.NASNetMobile",
]
)
def NASNetMobile(
input_shape=None,
include_top=True,View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/applications/nasnet.py:304 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/af4b1221f7fbe0f4.
Report an issue: GitHub.