Can the input of LSTM do not need hidden state?

username: Young19
cooked: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/6/76b13e86f9bae9a907db4dee15b4ee4ee30aadce.png" data-download-href="https://discuss.pytorch.org/uploads/default/76b13e86f9bae9a907db4dee15b4ee4ee30aadce" title="Screen Shot 2021-05-31 at 9.16.57 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/6/76b13e86f9bae9a907db4dee15b4ee4ee30aadce_2_690x255.png" alt="Screen Shot 2021-05-31 at 9.16.57 AM" data-base62-sha1="gW05iTzubrDgdYNrT4EriFCdyPk" width="690" height="255" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/6/76b13e86f9bae9a907db4dee15b4ee4ee30aadce_2_690x255.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/6/76b13e86f9bae9a907db4dee15b4ee4ee30aadce_2_1035x382.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/7/6/76b13e86f9bae9a907db4dee15b4ee4ee30aadce.png 2x" data-dominant-color="F0EDEC"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-31 at 9.16.57 AM</span><span class="informations">1294×480 65.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
I found that the input of the LSTM in the figure does not have a hidden state value. Does this setting make sense? So how does the LSTM obtain the value of the hidden state in the previous state during training?</p>

username: pascal_notsawo
cooked: <p>As can be seen in the source code, the initial hidden state and the initial cell state are all initialized to 0 in this case.</p><aside class="onebox githubblob">
  <header class="source">

      <a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/rnn.py#L662-L671" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/rnn.py#L662-L671" target="_blank" rel="noopener nofollow ugc">pytorch/pytorch/blob/master/torch/nn/modules/rnn.py#L662-L671</a></h4>



  <pre class="onebox">    <code class="lang-py">
      <ol class="start lines" start="662" style="counter-reset: li-counter 661 ;">
          <li>if hx is None:</li>
          <li>    num_directions = 2 if self.bidirectional else 1</li>
          <li>    real_hidden_size = self.proj_size if self.proj_size &gt; 0 else self.hidden_size</li>
          <li>    h_zeros = torch.zeros(self.num_layers * num_directions,</li>
          <li>                          max_batch_size, real_hidden_size,</li>
          <li>                          dtype=input.dtype, device=input.device)</li>
          <li>    c_zeros = torch.zeros(self.num_layers * num_directions,</li>
          <li>                          max_batch_size, self.hidden_size,</li>
          <li>                          dtype=input.dtype, device=input.device)</li>
          <li>    hx = (h_zeros, c_zeros)</li>
      </ol>
    </code>
  </pre>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>