# RuntimeError: tf.placeholder() is not compatible with eager execution. Use tf.keras.Input() instead.

- **ID:** `tensorflow/graph-mode-placeholder-in-eager`
- **Domain:** tensorflow
- **Category:** runtime_error
- **Error Code:** `EPLE`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

TensorFlow 2.x runs in eager mode by default, but the code uses tf.placeholder which is a graph-mode API removed in TF2.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.0 | active | — | — |
| 2.1 | active | — | — |
| 2.2 | active | — | — |
| 2.3 | active | — | — |

## Workarounds

1. **Replace all tf.placeholder calls with tf.keras.Input(shape=..., dtype=...) and rebuild the model using the Keras Functional API.** (95% success)
   ```
   Replace all tf.placeholder calls with tf.keras.Input(shape=..., dtype=...) and rebuild the model using the Keras Functional API.
   ```
2. **If you must use graph mode, wrap the code in a @tf.function decorator and use tf.compat.v1.placeholder inside a tf.compat.v1.Graph() context, but this is not future-proof.** (70% success)
   ```
   If you must use graph mode, wrap the code in a @tf.function decorator and use tf.compat.v1.placeholder inside a tf.compat.v1.Graph() context, but this is not future-proof.
   ```

## Dead Ends

- **Disable eager execution with tf.compat.v1.disable_eager_execution()** — Disabling eager execution may cause other TF2 features to break, and is not recommended for new code. (70% fail)
- **Replace placeholder with tf.Variable** — tf.Variable is for model parameters, not for input tensors; it will change the model semantics. (80% fail)
