C1W4A_Build_a_Conditional_GAN Grade issue

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’”,)

This is the justification for the 0/5 grade I got how ever I got for each section test, Success!

Also I got this after running UNQ_C4
Congratulations! If you’ve gotten here, it’s working. Please let this train until you’re happy with how the generated numbers look, and then go on to the exploration!

So why is there a problem with my grade?

If any exception gets thrown during grader execution, you get 0 for everything because it cannot complete.

This sounds like the issue on this thread.

I have same problem. Not compiling getting 0 grade even code runs very well. Not understand what is the problem.

Please show us the message under “Show grader output”. Perhaps that will be a clue as to what the issue is. As I mentioned above, any kind of exception from the grader results in 0 score, because it can’t complete the evaluation.

Thank you Paulinpaloalto for swift reply. I had wrong code types. Now corrected and solved the issue.
Thank you once again for your support.

1 Like

Could you pls tell me how to solve this problem? I met the same issue and tried to transform the type of labels too but it didn’t work​:smiling_face_with_tear:. I will very appreciated

Did you read this thread? Or are you referring to a different function?

Still having the same problem, changed the code to torch.cat((x,y),dim=1).float() to pass the test cell but it triggers the error:

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’”,)

In case of changing the code (assuming it is the cell#7) to torch.cat((x.float(), y.float()), dim=1) the grader error becomes:

Cell #7. Can’t compile the student’s code. Error: AssertionError()

can someone please help me here???

The second way to write it should have worked. Are you sure you did a ‘Save’ before you submitted to the grader?

My suggestion would be to first do this sequence:

Kernel -> Restart and Clear Output
Cell -> Run All

Then scan through the notebook and make sure all the tests pass. If they all pass, then do this

Kernel -> Restart and Clear Output
Save
Submit to grader

Then let us know if you still see the error you showed above.

Now that I think about this a bit more, another thing to check is that there are no other invocations of torch.cat in other cells. If so, you need to call combine_vectors instead of reimplementing it “in situ”.

Thanks, @paulinpaloalto ! It worked out as you described. All tests passed, no other calls of torch.cat. Now I can proceed. Many thanks!!

1 Like

That’s great news! Thanks for confirming.

Maybe it’s worth saying just a bit more about the implications of this way to submit for anyone else who sees this thread:

The point is that the grader does not need to see the output of your code in the notebook: it only needs to call your functions to test the results. Running the notebook can frequently increase the memory footprint quite a bit, especially in notebooks that involve training a model. Clearing the output before submitting makes the grading process as efficient as possible by minimizing the size of the notebook image that needs to get uploaded to the grader. There also are some edge cases where there is syntax in the generated output that can confuse the grader’s parser. Clearing the output also protects against that scenario.