I’ve been working on my ZerotoGANS Final submission assignment and I keep getting this error - RuntimeError: 1D target tensor expected, multi-target not supported whenever I try using crossentropy loss. What exactly is going wrong?
How many classes do you try to predict? (aka, how many outputs your network has).
I have 2 classes one is represented by 2 in the column and the other with a 4. Maybe that’s the issue? I tried making the output cols 2 though still same error
output_size was 1. It’s impossible to pick the most probable class out of only one possibility.
Changing it to 2 is ok - but your class “indices” are incorrect. They should start at 0. If you have only 2 or 4, then it not only doesn’t start at 0, but isn’t also continous.
If you have 2 classes to predict - they should be 0 or 1 ONLY. Which means you have to preprocess the dataset as for now.
Later - the loss function expects the
argmaxed outputs, along the batch dimension. You don’t have such thing in your model functions.
Thanks! I’ll try fixing these things!
I’m still a bit confused about the second part can you share where has this been implemented in the notebooks covered in course. I am not able to understand this.
This part - " Later - the loss function expects the
argmax ed outputs, along the batch dimension. You don’t have such thing in your model functions."
output.argmax() along the batch dimension.
Hey Thanks for the help
Sorry for bugging again I’m not able to grasp what’s going wrong now
So I did that in the loss function and got a new error now
I’ve committed it again am I again making some mistake the dim would be 1 right?
I tried dim 0 that didn’t work too
argmax is used mainly to predict the classes the images belong to,
cross_entropy accepts just output because it seems to apply some sort of
What happens if you just use output?
I get the same error if I just use output RuntimeError: 1D target tensor expected, multi-target not supported
I’ve committed it once again so you can check it out
squeeze() the targets. Ideally at preprocessing step, but can apply also in the model functions.
After some tweaking I got it to work
Thanks for all the help