{"record":{"id":"842be16021c3a948","repo":"keras-team/keras","slug":"input-tensor-input-tensor-is-not-type-input-tens","errorCode":null,"errorMessage":"input_tensor: {input_tensor}is not type input_tensor. Received `type(input_tensor)={type(input_tensor)}`","messagePattern":"input_tensor: (.+?)is not type input_tensor\\. Received `type\\(input_tensor\\)=(.+?)`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/applications/mobilenet_v2.py","lineNumber":138,"sourceCode":"\n    if weights == \"imagenet\" and include_top and classes != 1000:\n        raise ValueError(\n            'If using `weights=\"imagenet\"` with `include_top` '\n            f\"as true, `classes` should be 1000. Received `classes={classes}`\"\n        )\n\n    # Determine proper input shape and default size.\n    # If both input_shape and input_tensor are used, they should match\n    if input_shape is not None and input_tensor is not None:\n        try:\n            is_input_t_tensor = backend.is_keras_tensor(input_tensor)\n        except ValueError:\n            try:\n                is_input_t_tensor = backend.is_keras_tensor(\n                    operation_utils.get_source_inputs(input_tensor)\n                )\n            except ValueError:\n                raise ValueError(\n                    f\"input_tensor: {input_tensor}\"\n                    \"is not type input_tensor. \"\n                    f\"Received `type(input_tensor)={type(input_tensor)}`\"\n                )\n        if is_input_t_tensor:\n            if backend.image_data_format() == \"channels_first\":\n                if input_tensor.shape[1] != input_shape[1]:\n                    raise ValueError(\n                        \"input_shape[1] must equal shape(input_tensor)[1] \"\n                        \"when `image_data_format` is `channels_first`; \"\n                        \"Received `input_tensor.shape=\"\n                        f\"{input_tensor.shape}`\"\n                        f\", `input_shape={input_shape}`\"\n                    )\n            else:\n                if input_tensor.shape[2] != input_shape[1]:\n                    raise ValueError(\n                        \"input_tensor.shape[2] must equal input_shape[1]; \"","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/applications/mobilenet_v2.py#L120-L156","documentation":"MobileNetV2 input plumbing in keras/src/applications/mobilenet_v2.py: when both input_shape and input_tensor are given, the code probes whether input_tensor is a Keras tensor via backend.is_keras_tensor; if both the tensor and its source inputs fail that check, the object is not a valid Keras tensor and the builder cannot derive an Input from it.","triggerScenarios":"Thrown at keras/src/applications/mobilenet_v2.py:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a keras.Input object (or a Keras Tensor produced by a Keras layer) as input_tensor","Pass only input_shape and let the builder create the input","Convert raw frameworks tensors: wrap them with keras.Input or feed them through a Keras layer first"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}