Hi.
I recently refer two good reference. But I confused that output layer of these two is different.
First reference return ‘output’ term time-series-prediction-using-lstm
        self.hidden_cell = (torch.zeros(1,1,self.hidden_layer_size), torch.zeros(1,1,self.hidden_layer_size))
    def forward(self, input_seq):
        lstm_out, self.hidden_cell = self.lstm(input_seq.view(len(input_seq) ,1, -1), self.hidden_cell)
        predictions = self.linear(lstm_out.view(len(input_seq), -1))
        return predictions[-1]
       # Size
       # lstm_out          : [Seq_len(12), batch_size(1), 100]
       # predictions      : [Seq_len(12), 1]
       # predictions[-1] : (1,)

But,
Second reference return ‘hidden_cell’ term Time_Series_Prediction_with_LSTM 3
    def forward(self, x):
        h_0 = Variable(torch.zeros(self.num_layers, x.size(0), self.hidden_size))
        c_0 = Variable(torch.zeros(self.num_layers, x.size(0), self.hidden_size))

        # Propagate input through LSTM
        ula, (h_out, _) = self.lstm(x, (h_0, c_0))
        h_out = h_out.view(-1, self.hidden_size) 
        out = self.fc(h_out) 
        return out

What is difference between these two?
Thanks ahead.

torch.nn.LSTM



Input
input (seq_len, batch, input_size)
h_0 (num_layers * num_directions, batch, hidden_size)
c_0 (num_layers * num_directions, batch, hidden_size)




output
output(seq_len, batch, num_directions * hidden_size)
h_n(num_layers * num_directions, batch, hidden_size)
c_n(num_layers * num_directions, batch, hidden_size)