How to use custom label with image data set?

Hi. This is my first post here. I am a PyTorch newbie. I have written code for a convolution neural network that gives me an output. The forward pass works fine. I have loaded the dataset correctly and made the loader properly as well. Now, each image gives an output of 4 elements and this output is compared with a label which also consists of 4 elements (the label elements represent the bounding box coordinates).

The output of my forward pass gives a tensor of size 10 by 4 (I am using batch size of 10). To compute the loss I made a tensor of size 10 by 4. Each row of this tensor consists of the bounding box coordinate/ label for each image. I am trying to compute the loss using the following line

loss = criterion(outputs, all_bbox_tensor)

However, I get the following error:
Traceback (most recent call last):
File “C:/Users/sarim/PycharmProjects/thesis/pytorch_learning.py”, line 127, in
loss = criterion(outputs, all_bbox_tensor)
File “C:\Users\sarim\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “C:\Users\sarim\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\loss.py”, line 942, in forward
ignore_index=self.ignore_index, reduction=self.reduction)
File “C:\Users\sarim\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\functional.py”, line 2056, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File “C:\Users\sarim\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\functional.py”, line 1871, in nll_loss
ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
RuntimeError: multi-target not supported at …\aten\src\THNN/generic/ClassNLLCriterion.c:20

I don’t understand this error. What can I do to fix this?

Are you using Cross Entropy loss ? CrossEntropyLoss does not expect a one-hot encoded vector as the target, but class indices

Hello. Thank you very much. I solved the problem by using MSE to predict bounding box from image data. Thank you.