# ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, 64), dtype=tf.float32, name='input_2')) at layer 'dense_2'

- **ID:** `tensorflow/keras-functional-api-merging-bug`
- **Domain:** tensorflow
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 93%

## Root Cause

A Keras Functional API model has a disconnected graph because an intermediate tensor was not passed as input to a downstream layer, often due to incorrect merging of two sub-models or missing skip connection.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow 2.7 | active | — | — |
| tensorflow 2.8 | active | — | — |
| tensorflow 2.9 | active | — | — |

## Workarounds

1. **Trace the model definition and ensure every intermediate tensor used in a layer call is passed as an argument. For example, if merging two branches: merged = layers.concatenate([branch1_output, branch2_output]) then pass merged to the next layer. Check that all KerasTensors are connected in the functional graph.** (95% success)
   ```
   Trace the model definition and ensure every intermediate tensor used in a layer call is passed as an argument. For example, if merging two branches: merged = layers.concatenate([branch1_output, branch2_output]) then pass merged to the next layer. Check that all KerasTensors are connected in the functional graph.
   ```
2. **Use model.summary() and plot_model(model, show_shapes=True) to visualize the graph and identify the disconnected tensor, then correct the layer call that should use that tensor.** (90% success)
   ```
   Use model.summary() and plot_model(model, show_shapes=True) to visualize the graph and identify the disconnected tensor, then correct the layer call that should use that tensor.
   ```

## Dead Ends

- **** — The error is topological; adding layers does not automatically connect the missing tensor. (95% fail)
- **** — Sequential API does not support branching or merging, which is often the intended architecture. (80% fail)
