C1W4A_Build_a_Conditional_GAN Runtime Error

Hi,

I have a trouble regarding the aforementioned homework. When I run the cells, there is not any error. However, grader comes up with: 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’”,)

I checked what did I do, checked the cell 7 as well, however, I cannot find any issue. And cells are run perfectly. How can I solve this issue?

Best Regards,

Namazov

My theory is that you’ve written the code in such a way that it works with the test case in the notebook, but the code is not “general”. Meaning that it fails when the grader uses a different test case. The failure has something to do with indexing. It’s looking for an integer (Long) in a position, but getting a float. The reason that would fail is that it looks like that data is being used as some sort of index. Perhaps that will be enough of a clue for you to figure out which part of the code is at fault.

If those hints aren’t enough to help, then please let us know and there are other ways to follow up on that.

I already solved the issue. As you mentioned, my code was task specific rather than generic solution.

Thanks for your attention and help!

Regards,

Namazov

That’s great news that you found the solution under your own power. Thanks for confirming. Onward! :nerd_face:

Had the same issue here and fixed with the hints! :nerd_face:

Sorry for late response, and thanks for support! :slight_smile:

I had the same issue, with my grader failing but everything in the notebook working correctly. My error was:
Cell #8. 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’”,)

Here’s how I fixed it.

My combine_vectors routine was adding 2 vectors and required an output to be of type float. I used torch.cat().type(torch.float) initially. It passes all tests, but fails the grader. I changed it to individually modify the vectors, i.e. torch.cat((v1.float(),v2.float()…and removed the .type(torch.float) at the end. I hope this helps someone.

Glad to hear you found the solution on your own power. Yes, apparently the grader uses an older version of pytorch for some reason. This problem comes up pretty frequently, e.g. here’s another thread that’s more specific to your scenario.