This is the problem:



 safakhan:

out.reshape(-1, num_classes)


out has shape of (seq_len, batch, num_directions * hidden_size). You cannot simply reshape it like you do. It completely messes up you tensor.
By the way, this is a problem as well:
x.view(x.size(0), self.sequence_length, self.input_size)

See this post 1.