Yes, I tried thinks that people said it works for them
It sounds like it’s time to look at your code. Please check your DMs for a message from me. You can recognize a DM by the little envelope icon.
Hello @paulinpaloalto,
Can I know the reason behind why the float need to be applied separately to the variables?
I had used the same but applied the float to the both vectors being placed together and dim=1, and I did get pass the cell.
Can you please explain this variability of applying float separately?
Thank you in advance.
Regards
DP
The point is the behavior of torch.cat
in the older release that the grader is apparently using. That version of torch.cat
cannot handle arguments of different types. So whatever method you use needs to coerce the types both to float before invoking torch.cat
.
Thank you Paul for the response.
does this whole assignment need to be recalled with the same behaviour as I am having same error for other cells too.
Also your response raised another query in my mind, why cannot torch.cat function be immune to handling arguments of any type??
Regards
DP
This is just for the older version. The new one can handle this issue.
Hello @Nydia
Thank you for your response. But I am doing the latest assignment, and I am getting similar error again and again.
I am sharing grader output of my assignment
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’”,)
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’”,)
Even after doing the above correction, I still got 0 grader but all the test passed in the assignment.
As the model training for this assignment takes too much of time and internet, I just wanted to understand a permanent solution and why I am still getting this error even after apply the float separately as per the thread suggest as solution.
Thank you in advance.
Regards
DP
A permanent solution would be to update the PyTorch version from the cloud. But I do not think this is something that will be changed soon. Since this error has been for so long.
Right now, you would need to debug cell by cell. Ensure you are casting each cell properly the tensors.
Well, anytime you use torch.cat
, the same issue will happen, right? But if we are talking about the Conditional GANs exercise in C1 W4, then there should be only one occurrence of torch.cat
in that notebook. If you have more, what that means is that you should be calling combine_vectors
there instead of writing out the same code again. That’s the point of packaging it as a function: write the logic once and debug it once and then use it everywhere you need it.
But if this is some other assignment, then I don’t know what to say. I did not hit this same torch.cat
versionitis problem anywhere else, at least that I can recall off hand. But it’s been several years since I completed the GANs specialization, so it’s entirely possible that my memory is just failing me. Please let us know which assignment it is, if it’s not the one I referred to above.
Hello @paulinpaloalto
It is same assignment you are talking about C1 W4
N I did the correction as per instructions. Befor I didn’t have Cell 4 error but after doing the correction as per this post, after submission I got both Cell#4 and cell#7 error.
I don’t know why after cell 7 correction i got Cell 4 error also now where we write the return statement for one_hot label based on number of classes
Regards
DP
I think it is time to just look at your code. I’ll send you a DM about that.
Sorry Paul, I have deleted the file and starting a fresh. In case I still encounter the same grader output, wil share the codes.
Thank you
I was having the 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 fixed it by converting x.float() and y.float() in combine_vectors instead of converting the final tensor to a float. This is simply being posted to help others who encounter the same error.
Yes, that’s the correct solution. The problem here is that the grader apparently uses an older version of PyTorch in which the “cat” function is less forgiving about mismatching types.
Here’s another post earlier on this thread that explains it in a bit more detail.
Had used same Rajashri, my issue was related to network, when I tried again, I was able to pass the grader
Hi Paul,
Why do you say “of course” convert to float before combine? Is there a fundamental consideration there (other than some torch version issue).
Thank you
I was just explaining the significance of the way I wrote the code. The fundamental consideration is just that the torch.cat
primitive in the older version cannot handle mixed input types.
Hi Paul, I am facing the same issue.
This is how my code looks like:
combined = torch.cat((x.float(), y.float()), dim=1)
I haven’t used torch.cat() anywhere else
Exact output from the grader:
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'",)
Ok, maybe we need to look at your actual notebook. We can’t do that on a public thread, but I will send you a DM about how to proceed with that.
Just to close the loop on the public thread, Anant was able to resubmit and get the full points from the grader. Sounds like there was some inconsistency in the state of the notebook. All fixed now!