Answers.Body: <p>If you need to get an output from the LSTM as a vector in <span class="math-container">$\mathbb{R}^N$</span>, and the size of the hidden state is <span class="math-container">$1 \times M$</span>, you matmul with a learned <span class="math-container">$N \times M$</span> matrix. This is the linear layer.</p>
  <p>For example, if the problem is classification and you have <span class="math-container">$N$</span> classes, you might use the linear layer to project the hidden state to size <span class="math-container">$N$</span>, and then softmax to get logits.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-20T19:14:59.103Z
Answers.LastActivityDate: 2023-07-21T06:00:16.067Z
Answers.LastEditDate: 2023-07-21T06:00:16.067Z
Answers.UserDisplayName: Venna Banana
Body: <p>So basically I've read some text about LSTM, and luckily they mentioned the linear layer step at the end of the LSTM Process. However, they didn't explain how it works or what I would need to convert the hidden state into understandable and useable information. <strong>To be clear I do not want a Pytorch implementation of this.</strong> I am making my LSTM in C on arduino. If you don't know how to code in C or it is too time-consuming to make an example, a simple explanation without too much math detail, but enough that I get the basic idea of what to do is just as good. If you don't know how to explain it in a rookie friendly way, the article I found, which I mentioned above, does a pretty good job. The name is &quot;LSTM Networks | A Detailed Explanation&quot; by Rian Dolphin and can be found on towardsdatascience.com. I normally would give the link, but the last time I did that, people got mad.</p>
  <p>Thank you so much if you respond</p>
  <p>Edit: Wait, is it just another ANN on top of it.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-18T11:53:14.997Z
Comments.Text: I’m voting to close this question because this is a "write this code for me" post and seems to indicate the OP has not done minimal research first.
Comments.UserDisplayName: David Hoelzer
Tags: <neural-networks><recurrent-neural-networks><long-short-term-memory>
Title: How does the linear layer step work and what should I do at the end of the LSTM?
UserDisplayName: Anish Kommireddy
ThreadText: # How does the linear layer step work and what should I do at the end of the LSTM?
  
  (Asked by: username_0 on 2023-07-20)
  
  So basically I've read some text about LSTM, and luckily they mentioned the linear layer step at the end of the LSTM Process. However, they didn't explain how it works or what I would need to convert the hidden state into understandable and useable information. **To be clear I do not want a Pytorch implementation of this.** I am making my LSTM in C on arduino. If you don't know how to code in C or it is too time-consuming to make an example, a simple explanation without too much math detail, but enough that I get the basic idea of what to do is just as good. If you don't know how to explain it in a rookie friendly way, the article I found, which I mentioned above, does a pretty good job. The name is "LSTM Networks | A Detailed Explanation" by Rian Dolphin and can be found on towardsdatascience.com. I normally would give the link, but the last time I did that, people got mad.
  
  Thank you so much if you respond
  
  Edit: Wait, is it just another ANN on top of it.
  
  **Tags:** neural-networks, recurrent-neural-networks, long-short-term-memory
  
  > **Comments:**
  > **username_1**: I’m voting to close this question because this is a "write this code for me" post and seems to indicate the OP has not done minimal research first.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-07-20. Score: 0
  
  If you need to get an output from the LSTM as a vector in $\mathbb{R}^N$, and the size of the hidden state is $1 \times M$, you matmul with a learned $N \times M$ matrix. This is the linear layer.
  
  For example, if the problem is classification and you have $N$ classes, you might use the linear layer to project the hidden state to size $N$, and then softmax to get logits.
  
  
  ---
  
  