# OutOfRangeError: 序列结束

- **ID:** `tensorflow/out-of-range-end-of-sequence`
- **领域:** tensorflow
- **类别:** data_error
- **错误码:** `EOS`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

tf.data 迭代器在训练循环预期结束前已耗尽，通常是由于数据集大小与步数不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| tensorflow 2.9.0 | active | — | — |
| tensorflow 2.10.0 | active | — | — |
| tensorflow 2.11.0 | active | — | — |

## 解决方案

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`.
   ```

## 无效尝试

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