title: what does nn.Linear() do in pytorch's last, and why is it necessary?
body: <p>I am working with some code that trains an lstm to generate sequences. After training the model, the lstm() method is called:</p>
  
  <pre><code>x = some_input
  lstm_output, (h_n, c_n) = lstm(x, hc) 
  funcc = nn.Linear(in_features=lstm_num_hidden,
                    output_features=vocab_size,
                    bias=True)
  func_output = func(lstm_output)
  </code></pre>
  
  <p>I've looked at the documentation for <code>nn.Linear()</code> but I still don't understand what this transformation is doing and why it is necessary. If the lstm has already been trained, then the output it gives should already have a pre-established dimensionality. This output (lstm_output) would be the generated sequence, or in my case an array of vectors. Am I missing something here?</p>