When I submit the assignment, I get the following error and I can’t pass the assignment although I solved all the questions correctly.
Cell #7. Can’t compile the student’s code. Error: RuntimeError(“Expected object of scalar type Long but got scalar type Float for sequence element 1 in sequence argument at position #1 ‘tensors’”).
Hi Abdullah!
Hope you are doing well. Can you be more specific about the assignment number? (4A or 4B -Conditional GAN or Controllable GAN) and if possible send me your notebook through a Private message so that I can point out specifically where the issue is.
Regards,
Nithin
I just replaced the test-check code cell #7 with another one (I searched for another solved assignment online), although it was look like it, I found the problem was solved and I can’t know how !!!
I think this is another case in which the torch version that the grader is using is less permissive than the one in the notebook. It looks like the grader’s version of torch.cat can’t handle different types. I wrote that code like this and it passes the grader:
combined = torch.cat((x.float(), y.float()), dim = 1)
The point is that I do the conversion to floatbefore the cat, of course.
Cell #UNQ_C4. Can’t compile the student’s code. Error: RuntimeError(“Expected object of scalar type Float but got scalar type Long for sequence element 1 in sequence argument at position #1 ‘tensors’”,)
The problem is that your combine_vectors code is correct and agrees with the solution above, but that doesn’t help if you don’t actually call it. You are directly doing torch.cat instead of calling combine_vectors.
i used this code but not complie error shows
ell #UNQ_C4. Can’t compile the student’s code. Error: RuntimeError(“Expected object of scalar type Float but got scalar type Long for sequence element 1 in sequence argument at position #1 ‘tensors’”,)
Are you sure you used that code everywhere? There should be only one call to torch.cat in the whole notebook and that is within the scope of the combine_vectors function. If you directly call torch.cat elsewhere, that is a mistake. Well, you can make it work by fixing the same issue everywhere, but you’re working harder than you need to.
I run to the same issue. The problem is that the cell output is kind of misleading. I have got the “Congratulations …” message, network trained and worked. But the grader shows the error because of my wrong approach to torch.cat usage. The key to solution was here in the discussion, there should be only one usage of torch.cat in the notebook.
Are you sure that you are calling combine_vectors everywhere, instead of manually re-implementing it in some places? You have fix the logic in combine_vectors and then make sure you are actually calling it everywhere it is needed. There should be no other occurrences of torch.cat in your notebook.