I think i have seen where the error is coming from, i changed the runtime type to cpu …
This is the size of my dataset from the getitem  (5, 3, 256, 256) and i added this line of code (#Edit label tensor to remove channel since nn.CrossEntropy Loss() receives (B, H, W)
mask_array = torch.cat((mask_array[:1], mask_array[256:]))
mask_array = torch.squeeze(mask_array, 0))
to squeeze only the mask(label) to (5, 256,256)
for my training i have this:
outputs = model(inputs)
print(type(outputs))
labels = labels.long()
loss = criterion(outputs[‘out’], labels) ## the error is coming from here
_, preds = torch.max(outputs[‘out’], 1)
# backward + optimize
loss.backward()
optimizer.step()
still ended up with this error : IndexError: Target -2 is out of bounds
Thanks for your help