# Hidden/cell state initialisation with Variable or without Variable?

**URL:** <https://discuss.pytorch.org/t/hidden-cell-state-initialisation-with-variable-or-without-variable/84148>\
**Category:** Uncategorized\
**Created:** [June 4, 2020, 8:21am UTC](https://discuss.pytorch.org/t/hidden-cell-state-initialisation-with-variable-or-without-variable/84148 "2020-06-04T08:21:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Talita](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/t/977dab/32.png) [@Talita](https://discuss.pytorch.org/u/Talita)\
**Post date:** [June 4, 2020, 8:21am UTC](https://discuss.pytorch.org/t/hidden-cell-state-initialisation-with-variable-or-without-variable/84148/1 "2020-06-04T08:21:32Z")

</div>

Hi,

I am just wondering about how we should initialise the hidden/cell state of the LSTM if we want something different than just zeros. I usually do it like this (just using the example in the docs):

```auto
>>> rnn = nn.LSTM(10, 20, 2)
>>> input = torch.randn(5, 3, 10)
>>> h0 = torch.randn(2, 3, 20)
>>> c0 = torch.randn(2, 3, 20)
>>> output, (hn, cn) = rnn(input, (h0, c0))

```

But I have also seen examples that use `Variable` or even the example mentioned here: [Correct way to declare hidden and cell states of LSTM](https://discuss.pytorch.org/t/correct-way-to-declare-hidden-and-cell-states-of-lstm/15745).

I suppose that Variable allows the model to “learn” a correct initialisation of the hidden state. Is that correct???
