Expected object of scalar type Short but got scalar type Float for argument #2 'mat2' in call to _th_mm
I have data type problem implementing LSTM with Pytorch. Based on similar problems I tried to change the format of Input, h and c to ShortTensor as you can see but I still get the same error:


  RuntimeError: Expected object of scalar type Short but got scalar type
  Float for argument #2 'mat2' in call to _th_mm


class data(Dataset):
    def __init__(self, samples=10000, number=30):
        self.x = torch.from_numpy(np.matrix
                        (np.random.random_integers(0,9,samples*number).reshape(samples, number)))
        self.y = torch.from_numpy(np.zeros((samples))).type(torch.ShortTensor)
        for index, row in enumerate(self.x):
            self.y[index] = 1 if torch.sum(row) &gt;= 130 else 0

class LSTM(nn.Module):
    def __init__(self,i_size, h_size, n_layer, batch_size = 30 ):
        super().__init__()
        self.lstm = nn.LSTM(input_size=i_size, hidden_size=h_size, num_layers=n_layer)
        self.h = torch.randn(n_layer, batch_size, h_size).type(torch.ShortTensor)
        self.c = torch.randn(n_layer, batch_size, h_size).type(torch.ShortTensor)
        self.hidden = (self.h, self.c)
        self.linear = nn.Linear(n_layer, 1)

    def forward(self,x):
        out, hidden = self.lstm(x.type(torch.ShortTensor), self.hidden)
        out = nn.Softmax(self.linear(out.short()))
        return out

data_set = data()
train_data = data_set.x[0:8000, :, None]
train_label = data_set.y[0:8000]
test_data = data_set.x[8000:, : , None]
test_label = data_set.y[8000:]

input_size = 1
hidden_size = 30
layer_num = 200
model_LSTM = LSTM(input_size, hidden_size, layer_num)
#model_LSTM.cuda()
y_ = model_LSTM(train_data)


I was producing the input data in int16 and apparently nn.LSTM takes only float32 and the error wasn't clear about that.  
