A problem about LSTM forward propagation result

fan_zhimin: <p>When I set the sequence length to 1, Output vector and result [0] are the same.<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/2/926fa855d514dfa06ac75806340eab5ff11d0d07.png" data-download-href="https://discuss.pytorch.org/uploads/default/926fa855d514dfa06ac75806340eab5ff11d0d07" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/2/926fa855d514dfa06ac75806340eab5ff11d0d07_2_690x363.png" alt="image" data-base62-sha1="kTqW1C6LZprB7MpOR7L1PIZQ0JN" width="690" height="363" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/2/926fa855d514dfa06ac75806340eab5ff11d0d07_2_690x363.png, https://discuss.pytorch.org/uploads/default/optimized/3X/9/2/926fa855d514dfa06ac75806340eab5ff11d0d07_2_1035x544.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/9/2/926fa855d514dfa06ac75806340eab5ff11d0d07_2_1380x726.png 2x" data-dominant-color="3F4042"><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">image</span><span class="informations">1911×1008 144 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>
If the sequence length is not equal to 1 , Output vector is not equal to hidden state vector.<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/1/b1fecc9c01bdb5d188f2bb862be413133c5506b5.png" data-download-href="https://discuss.pytorch.org/uploads/default/b1fecc9c01bdb5d188f2bb862be413133c5506b5" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/b/1/b1fecc9c01bdb5d188f2bb862be413133c5506b5.png" alt="image" data-base62-sha1="poCpRy6Q0WGt0nbuInJuLI2EzNH" width="690" height="88" data-dominant-color="564A53"><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">image</span><span class="informations">1117×143 14 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>
Who can tell me why. And how to calculate the output vector at this time. And what’s the meaning</p>

ptrblck: <p>Could you explain your use case a bit more and post a code snippet so that we can have a look, please?</p>
<p>PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier. <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"></p>

nibor: <p>Please look here <a href="https://github.com/pytorch/pytorch/blob/eae1b40400df2b3e6d777bcaaf60f338749cad0f/torch/nn/modules/rnn.py#L666" class="inline-onebox" rel="noopener nofollow ugc">pytorch/rnn.py at eae1b40400df2b3e6d777bcaaf60f338749cad0f · pytorch/pytorch · GitHub</a></p>
<p>The output tensor contain the hidden states for all the sequence lengths and result [1] tensor contain the hidden states just of the very last sequence length .</p>