RuntimeError: one_hot is only applicable to index tensor. #454
Answered
by
MKaczkow
talhaanwarch
asked this question in
Q&A
-
|
Ground truth shape : I also tried removing |
Beta Was this translation helpful? Give feedback.
Answered by
MKaczkow
Jun 7, 2024
Replies: 2 comments 4 replies
-
|
Try to squeeze ground truth tensor |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
I have the same problem. Can you ask me how to solve it? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For anyone looking for answer: gt input tensor (
y_pred) must have typetorch.LongTensor(ortorch.cuda.LongTensor). If not, this line:from smp.losses module fails. This is also described on SO. Though it's unclear for me why
LongTensoris specifically required intorch.nn.functional.one_hot(any integer type would do, I guess?), the docs state it is and.long()solves problem.