I read all posts regarding the same problem but couldn’t figure my error out.
def main(A, B, num_epochs): n = A.shape dim = A.shape C = range(0, n - 1) train_loader = zip(A, B, C) # Training the Model for epoch in range(num_epochs): shuffle(train_loader) for (x, y, i) in train_loader: x = Variable(torch.FloatTensor(x), requires_grad=False) y = Variable(torch.FloatTensor(y), requires_grad=False)
RuntimeError: already counted a million dimensions in a given sequence. Most likely your items are also sequences and there’s no way to infer how many dimension should the tensor have
The error occurs when calling
x = Variable(torch.FloatTensor(x), requires_grad=False)
I also tried:
x = Variable(torch.FloatTensor(x).data, requires_grad=False)
which resulted in the same error.
The reason I added x conversion to torch because otherwise I get this error:
x = Variable(x, requires_grad=False)
RuntimeError: Variable data has to be a tensor, but got matrix
x.shape and y.shape are (1,300)