hi, I have tried your implementation on its own and it works perfectly.
But now that I tried integrating it in my program, I get the following error:
--> 707         y_plusone.scatter_(1, targets, 1)
    708 
    709         return y_plusone.to(self.device)

RuntimeError: invalid argument 3: Index tensor must be either empty or have same dimensions as output tensor at /pytorch/aten/src/THC/generic/THCTensorScatterGather.cu:318


the function is the following
def to_plusone(self, targets):
        """ Convert targets to +1/-1 encoding for hinge loss """

        num_classes = self.net.fc.out_features
        batch_size = targets.size()[0]
        y_plusone = -1 * torch.ones(batch_size, num_classes).long().cuda()
        y_plusone.scatter_(1, targets, 1)

        return y_plusone.to(self.device)

the target arguments are a batch of labels from the dataloader of cifar100
I also checked the size of the targets :
torch.Size([64])

while the size of the y_plusone tensor is :
torch.Size([64, 10])

can you see something wrong? Thank you and sorry for bothering you