One-hot encoding problem

Hello,

I am building a model for multiclass prediction for targets [-1,0,1] and currently getting an error from loss function that

Target -1 is out of bounds.

Well, it is a good idea to encode classes with torch.nn.functional.one_hot , but I can’t encode negative values, as I know. Is there any other alternatives or solutions of how to encode or directly feed my targets?

Couldn’t you have targets [0,1,2] if the -1 is causing the issue? Could you share some code snippet to how it looks like now

1 Like