# OutOfRangeError: End of sequence

- **ID:** `tensorflow/out-of-range-end-of-sequence`
- **Domain:** tensorflow
- **Category:** data_error
- **Error Code:** `EOS`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A tf.data iterator was exhausted before the training loop expected, often due to a mismatch between dataset size and number of steps.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow 2.9.0 | active | — | — |
| tensorflow 2.10.0 | active | — | — |
| tensorflow 2.11.0 | active | — | — |

## Workarounds

1. **Ensure the dataset is repeated or the number of steps matches the dataset size. For example: `dataset = dataset.repeat()` and then `steps_per_epoch = len(dataset) // batch_size`.** (95% success)
   ```
   Ensure the dataset is repeated or the number of steps matches the dataset size. For example: `dataset = dataset.repeat()` and then `steps_per_epoch = len(dataset) // batch_size`.
   ```

## Dead Ends

- **** — This does not fix the mismatch; it only changes the number of elements per step. (85% fail)
- **** — An infinite repeat (repeat()) can mask the error but leads to infinite loops if not handled. (90% fail)
