Hello,
I have a problem that I don’t understand. It concerns the CrossEntropyLoss function. I am currently working on segmentation of a certain type of pattern in medical images. For this, I have built an architecture that returns after a softmax an array of output images of the form: [N, C, H, W] where N is the size of my batch, C the number of channels in each image and H, W the height and width of my image respectively. However, when I enter something of the form [10, 1, 240, 240] for my outputs and [10, 240, 240] for my targets, it always returns:

IndexError: Target 1 is out of bounds.

I’ve seen many things on the forums. Each time it mentions “classes” but I don’t understand what that means. It seems to correspond to my number of channels for my output images (in my case 1 because they are 2D binary images) however it doesn’t work. I think I’m missing something.
Could someone please enlighten me?
I am attaching the few lines in question.
        # inputs => [10, 3, 240, 240]
        outputs = segnetModel(images)

        # outputs => [10, 1, 240, 240]
        # targets => [10, 240, 240]
        loss = cost(outputs, labels)

I also found a question on the forum that is very close to what I wanted but still talks about “classes” : The cost function for semantic segmentation?
Thank you very much for your help in advance.