# Stateful RNN example

**URL:** <https://discuss.pytorch.org/t/stateful-rnn-example/10912>\
**Category:** Uncategorized\
**Created:** [December 8, 2017, 5:03am UTC](https://discuss.pytorch.org/t/stateful-rnn-example/10912 "2017-12-08T05:03:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jodles](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/j/8edcca/32.png) [@jodles](https://discuss.pytorch.org/u/jodles)\
**Post date:** [December 8, 2017, 9:13am UTC](https://discuss.pytorch.org/t/stateful-rnn-example/10912/2 "2017-12-08T09:13:02Z")

</div>

This thread may be relevant: [[Solved] Training a simple RNN](https://discuss.pytorch.org/t/solved-training-a-simple-rnn/9055)

A key point is that to keep hidden state Variable across batches without having to specify `retain_graph=True` you need to detach the Variable: `hidden.detach()`.

---

_[View the full topic](https://discuss.pytorch.org/t/stateful-rnn-example/10912)._
