keras-team/keras · error · ValueError
input_tensor specified
Error message
input_tensor specified: {input_tensor}is not a keras tensor What it means
MobileNetV3 builder in keras/src/applications/mobilenet_v3.py: an input_tensor was provided (with input_shape also set) that failed the backend.is_keras_tensor check, so it is not a Keras symbolic tensor the model can attach to — commonly a NumPy array or eager tensor.
Solutions
- Use keras.Input(shape=...) to create input_tensor
- Omit input_tensor and pass input_shape only
- Wrap intermediate tensors as Keras layer outputs before reusing them as model inputs
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at keras/src/applications/mobilenet_v3.py:224 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/b596a60f7cc64adb.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/applications/mobilenet_v3.py:224
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]:
raise ValueError(
"input_shape[1] must equal "
"input_tensor.shape[2]. Received "
f"input_shape={input_shape}, "
"input_tensor.shape="
f"{input_tensor.shape}"
)
else:
raise ValueError(
"input_tensor specified: ",
input_tensor,
"is not a keras tensor",
)
# If input_shape is None, infer shape from input_tensor
if input_shape is None and input_tensor is not None:
try:
backend.is_keras_tensor(input_tensor)
except ValueError:
raise ValueError(
"input_tensor: ",
input_tensor,
"is type: ",
type(input_tensor),
"which is not a valid type",
)
View on GitHub (pinned to 7a34a03db6)