shwe87:

h = model.init_hidden(batch_size)


I initialized the hidden weights with zeros at first:
h = model.init_hidden(batch_size)
The init_hidden function is inside the model’s class
if (train_on_gpu):
hidden = (torch.zeros(self.n_layersself.n_direction, batch_size, self.hidden_dim).zero_()).cuda()
else:
hidden = (torch.zeros(self.n_layersself.n_direction, batch_size, self.hidden_dim).zero_())