# Does training\_iteration correspond to number of episodes?

**URL:** <https://discuss.ray.io/t/does-training-iteration-correspond-to-number-of-episodes/5125>\
**Category:** RLlib\
**Created:** [February 18, 2022, 3:38pm UTC](https://discuss.ray.io/t/does-training-iteration-correspond-to-number-of-episodes/5125 "2022-02-18T15:38:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlorop](https://avatars.discourse-cdn.com/v4/letter/c/b19c9b/32.png) [@carlorop](https://discuss.ray.io/u/carlorop)\
**Post date:** [February 18, 2022, 3:38pm UTC](https://discuss.ray.io/t/does-training-iteration-correspond-to-number-of-episodes/5125/1 "2022-02-18T15:38:05Z")

</div>

According to the documentation, ‘training\_iteration’ counts the number of times `tune.report()` has been called. Would that always be equivalent to the number of training episodes when training a RL agent on RLLIB?

---

<div class="post-metadata">

**Author:** ![Lars\_Simon\_Zehnder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/lars_simon_zehnder/32/1185_2.png) [@Lars\_Simon\_Zehnder](https://discuss.ray.io/u/Lars_Simon_Zehnder)\
**Post date:** [February 19, 2022, 10:41am UTC](https://discuss.ray.io/t/does-training-iteration-correspond-to-number-of-episodes/5125/2 "2022-02-19T10:41:58Z")

</div>

Hi @carlorop ,

`training_iteration` does count the number of iterations in which a training step has been made. This is however not identical with the number of episodes in RLlib. The reason for this is that whenever the `RolloutWorker`s in RLlib collect new experiences from the environment they can do so either, by using a predefined number of steps in the environment or by stepping for as long as an episode takes. We define one or the other by setting `batch_mode` to either `truncate_episodes` (the **default** ) or `complete_episodes`. These settings define what data gets collected into a training batch.

Note, a training batch can then contain multiple episodes for both cases, however, `complete_episodes` ensures that there are always complete episodes in the training batch (as long as there is no `horizon` set).

Coming back to your question now: A single training batch usually contains not a single episode and as the `Trainer` trains on a batch `training_iteration` and number of episodes stepped in the environment are not the same.

For the configuration setting take a look into the [`Trainer` configuration](https://docs.ray.io/en/latest/rllib-training.html#common-parameters).

Hope this helps
