keras-team/keras · error · ValueError
input_tensor: is not type input_tensor. Received…
Error message
input_tensor: {input_tensor}is not type input_tensor. Received type(input_tensor)={type(input_tensor)} What it means
MobileNetV3 input plumbing in keras/src/applications/mobilenet_v3.py: with both input_shape and input_tensor given, the builder probes input_tensor with backend.is_keras_tensor; when the tensor and its source inputs both fail, the object is not a Keras tensor and cannot serve as the model input. Typically a NumPy array or eager tensor was passed.
Solutions
- Pass a keras.Input object as input_tensor
- Pass only input_shape and let the builder construct the input
- Feed foreign tensors through a Keras layer to obtain a symbolic Keras tensor first
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at keras/src/applications/mobilenet_v3.py:197 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/66c10020633ea93a.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/applications/mobilenet_v3.py:197
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:
is_input_t_tensor = backend.is_keras_tensor(input_tensor)
except ValueError:
try:
is_input_t_tensor = backend.is_keras_tensor(
operation_utils.get_source_inputs(input_tensor)
)
except ValueError:
raise ValueError(
"input_tensor: ",
input_tensor,
"is not type input_tensor. "
f"Received type(input_tensor)={type(input_tensor)}",
)
if is_input_t_tensor:
if backend.image_data_format() == "channels_first":
if input_tensor.shape[1] != input_shape[1]:
raise ValueError(
"When backend.image_data_format()=channels_first, "
"input_shape[1] must equal "
"input_tensor.shape[1]. Received "
f"input_shape={input_shape}, "
"input_tensor.shape="
f"{input_tensor.shape}"
)
else:
if input_tensor.shape[2] != input_shape[1]:View on GitHub (pinned to 7a34a03db6)