How to iterate over two dataloaders simultaneously using pytorch?

后端 未结 5 618
星月不相逢
星月不相逢 2021-02-06 06:04

I am trying to implement a Siamese network that takes in two images. I load these images and create two separate dataloaders.

In my loop I want to go through both datalo

5条回答
  •  滥情空心
    2021-02-06 06:31

    I see you are struggling to make a right dataloder function. I would do:

    class Siamese(Dataset):
    
    
        def __init__(self, transform=None):
        
           #init data here
        
        def __len__(self):
            return   #length of the data
    
        def __getitem__(self, idx):
            #get images and labels here 
            #returned images must be tensor
            #labels should be int 
            return img1, img2 , label1, label2 
    

提交回复
热议问题