# InternalError: CUDNN_STATUS_BAD_PARAM: Invalid weight format for cuDNN RNN. Expected format: [num_layers, input_size, num_units] but got [3, 128, 64].

- **ID:** `tensorflow/cudnn-rnn-weight-format-error`
- **Domain:** tensorflow
- **Category:** runtime_error
- **Error Code:** `CRWF`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The weight tensor passed to cuDNN RNN has an incorrect shape or layout, often due to a mismatch between the model's RNN configuration and the actual weight initialization.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow==2.9.0 | active | — | — |
| tensorflow==2.11.0 | active | — | — |
| tensorflow==2.14.0 | active | — | — |

## Workarounds

1. **Ensure the RNN layer is initialized with the correct input shape and units, and use `return_sequences=True` if the next layer expects 3D output.** (85% success)
   ```
   Ensure the RNN layer is initialized with the correct input shape and units, and use `return_sequences=True` if the next layer expects 3D output.
   ```
2. **Use `tf.keras.layers.RNN` with a custom cell that explicitly defines weight shapes to avoid cuDNN assumptions.** (75% success)
   ```
   Use `tf.keras.layers.RNN` with a custom cell that explicitly defines weight shapes to avoid cuDNN assumptions.
   ```

## Dead Ends

- **** — Changing the RNN type (e.g., LSTM to GRU) does not fix the weight shape issue; it may introduce new shape requirements. (85% fail)
- **** — Increasing the number of units exacerbates the mismatch because weight dimensions become larger but still wrong. (90% fail)
