dataloader does not return correct target tensor
I am writing custom dataset but the dataloader does not return correct target tensors.

where the label is 010 I am getting 10. 

I am converting the labels into int before converting to tensor. 

  y_label = torch.tensor(int(self.annotations.iloc[index, 1]))


iterating through dataloader: 

Batch idx 0, data shape torch.Size([1, 1, 56, 128, 128]), target shape torch.Size([1])
tensor([1])
Batch idx 1, data shape torch.Size([1, 1, 56, 128, 128]), target shape torch.Size([1])
tensor([100])
Batch idx 2, data shape torch.Size([1, 1, 56, 128, 128]), target shape torch.Size([1])
tensor([10])
Batch idx 3, data shape torch.Size([1, 1, 56, 128, 128]), target shape torch.Size([1])
tensor([1])


csv file looks like the following:  

1 p0.npy, 100
2 pl.npy, 001
3 p2.npy, 001
4 p3.npy, 001
5 p4.npy, 100
6 p5.npy, 010
7 p6.npy, 100
8 p7.npy, 100
9 p8.npy, 100
10 p9.npy, 010
11 plO.npy, 010
12 pll.npy, 010
13 p12.npy, 010
14 p13.npy, 100


code:

class patientdataset(Dataset):


    def __init__(self, csv_file, root_dir, transform=None):


            self.annotations = pd.read_csv(csv_file)
            self.root_dir = root_dir
            self.transform = transform



    def __len__(self):
        return len(self.annotations)

    def __getitem__(self, index):

        img_path = os.path.join(self.root_dir, self.annotations.iloc[index,0])
        # np_load_old = np.load
        # np.load = lambda *a, **k: np_load_old(*a, allow_pickle=True, **k)

        image= np.array(np.load(img_path))

        # y_label = torch.tensor(np.asarray(self.annotations.iloc[index,1]))

        y_label = torch.tensor(int(self.annotations.iloc[index, 1]))


        if self.transform:
            imagearrays = self.transform(image)
            image = imagearrays[None, :, :, :]
            imaget = np.transpose(image, (0, 2, 1, 3))
            image = imaget


        return (image, y_label)


It seems your labels are in binary form. 
Convert them into decimal and then into tensor should do the trick for you.

y_label = torch.tensor(int(self.annotations.iloc[index, 1], 2))


doing so will convert 010 into 2, 100 into 4 and so on.
