# Understanding state\_batches in compute\_actions

**URL:** <https://discuss.ray.io/t/understanding-state-batches-in-compute-actions/3001>\
**Category:** RLlib\
**Created:** [July 24, 2021, 10:20am UTC](https://discuss.ray.io/t/understanding-state-batches-in-compute-actions/3001 "2021-07-24T10:20:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [July 24, 2021, 11:34am UTC](https://discuss.ray.io/t/understanding-state-batches-in-compute-actions/3001/2 "2021-07-24T11:34:20Z")

</div>

Hi @Lars_Simon_Zehnder,

I saw you liked my post on states in rllib.

In there I mentioned

“When you are using an rnn you only get the initial state of the sequence. The other states are generated internally by the rnn logic.”

Thisius likely the issue. To verify this, check the shape of [obs, seq\_lens, and state\_in\_0[0]] and see how they compare. If this is the issue you will see that obs batch size is larger than seq\_lens and state\_in\_0 is equal to seq\_lens.

An option that might work is to use a different name for the trajectory view variable that tracks state\_in that does not include state in the key. This might circumvent the special state handling when preparing the sample batch. I am just guessing here.

> [@\[rllib\] SampleBatch "state\_in\_0" dimension shorter than expected](https://discuss.ray.io/t/rllib-samplebatch-state-in-0-dimension-shorter-than-expected/2354/4):
>
> What is your max\_seq\_len? Before passing the model into forwad\_rnn two things happen. 1. The data in the sample batch is padded so that all inputs are the same size as your longest episode. So if you had sequences of length [5,12,10,4] they would all be padded with zeros to be 12 steps long. You would end up with a total of12 \* 4 timesteps in your sample batch. They are also shortened to be no larger than max sequence length. Let’s say your max\_seq\_len in the model config was 20. Your state in …

---

_[View the full topic](https://discuss.ray.io/t/understanding-state-batches-in-compute-actions/3001)._
