Class index has been well solved as your reply.
But I had another problem…
for x in [numpy_data, numpy_target]:
    print(x.min(), x.max())

When I loaded numpy files having shape (480,512,512),
I got for input min: 0, max: 499
target min: 0, max: 3
I use Normalize function as follow :
def normalize(img):   
    arr = img.copy().astype(np.float32)
    M = np.float32(np.max(img))
    if M != 0:
        arr *= 1./M
    return arr

And i use Dataset as follow:
class trainDataset(torch.utils.data.Dataset):
    def __init__(self, data, target, transform=None):
        self.data = data.astype(np.float32)
        self.data = normalize(data)

        self.target = target.astype(np.float32)
        self.target = normalize(target)

        self.transform = transform
        
    def __getitem__(self, index):
        x = self.data[index]
        y = self.target[index]
        
        if self.transform:
            x = self.transform(x)

        return x, y
    
    def __len__(self):
        return len(self.data)

transform = transforms.Compose([transforms.ToPILImage(mode=None),
                                                       transforms.Resize(512),
                                                       transforms.ToTensor()
                                                       ])

traindataset = trainDataset(train_numpy_data, train_numpy_target ,transform = transform)
validdataset = trainDataset(valid_numpy_data, valid_numpy_target ,transform = transform)                

trainloader = torch.utils.data.DataLoader(traindataset, batch_size = batch_size, shuffle=True, num_workers=0, pin_memory=False)
validloader = torch.utils.data.DataLoader(validdataset, batch_size = batch_size, shuffle=True, num_workers=0, pin_memory=False)

inputs, masks = next(iter(trainloader))
print(inputs.shape, masks.shape)
print(inputs.min(), inputs.max())
print(masks.min(), masks.max())

I got :
torch.Size([4, 1, 512, 512]) torch.Size([4, 512, 512])
tensor(0.) tensor(0.7675)
tensor(0.) tensor(0.)
I don’t know why min-max value doesn’t get 0-1…
It’s annoying, but i’d really appreciate it if you help me once more.
Thank you!