In the Sentiment_RNN_Solution.ipynb, the forward pass is getting all time steps output from the LSTM and pass it to the next fully connected layer. The filtering process only happens in the last step.
lstm_out, hidden = self.lstm(embeds, hidden)
# stack up lstm outputs
lstm_out = lstm_out.contiguous().view(-1, self.hidden_dim) <----------- stacking the all time steps output
# dropout and fully-connected layer
out = self.dropout(lstm_out)
out = self.fc(out)
# sigmoid function
sig_out = self.sig(out)
# reshape to be batch_size first
sig_out = sig_out.view(batch_size, -1)
sig_out = sig_out[:, -1] # get last batch of labels <----------- Omiting all but the last time step output
unnecessary calculations happen in the middle of the forward pass.
In the Sentiment_RNN_Solution.ipynb, the forward pass is getting all time steps output from the LSTM and pass it to the next fully connected layer. The filtering process only happens in the last step.
unnecessary calculations happen in the middle of the forward pass.