Using torch.nn’s GRU gives the error Expected object of scalar type Long but got scalar type Float for argument #2 ‘mat2’. I converted the input before passing it to the gru and also printed its type() to verify that it is a Long tensor.
in1 = x.unsqueeze(0).type(torch.LongTensor).
in2 = (hxs * masks).unsqueeze(0).type(torch.LongTensor).
print(in1.type(),in2.type()) #Gives torch.cuda.LongTensor
x, hxs = self.gru(in1, in2)
The gru is defined as self.gru = nn.GRU(recurrent_input_size, hidden_size).cuda()