# Help clarifying repackage\_hidden in word\_language\_model

**URL:** <https://discuss.pytorch.org/t/help-clarifying-repackage-hidden-in-word-language-model/226>\
**Category:** Uncategorized\
**Created:** [January 27, 2017, 10:21pm UTC](https://discuss.pytorch.org/t/help-clarifying-repackage-hidden-in-word-language-model/226 "2017-01-27T22:21:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![apaszke](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/apaszke/32/21_2.png) [@apaszke](https://discuss.pytorch.org/u/apaszke)\
**Post date:** [January 27, 2017, 11:12pm UTC](https://discuss.pytorch.org/t/help-clarifying-repackage-hidden-in-word-language-model/226/2 "2017-01-27T23:12:56Z")

</div>

Every variable has a `.creator` attribute that is an entry point to a graph, that encodes the operation history. This allows autograd to replay it and differentiate each op. So each hidden state will have a reference to some graph node that has created it, but in that example you’re doing BPTT, so you never want to backprop to it after you finish the sequence. To get rid of the reference, you have to take out the tensor containing the hidden state `h.data` and wrap it in a fresh `Variable`, that has no history (is a graph leaf). This allows the previous graph to go out of scope and free up the memory for next iteration.

---

_[View the full topic](https://discuss.pytorch.org/t/help-clarifying-repackage-hidden-in-word-language-model/226)._
