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
If you want to iterate over two datasets simultaneously, there is no need to define your own dataset class just use TensorDataset like below:
dataset = torch.utils.data.TensorDataset(dataset1, dataset2)
dataloader = DataLoader(dataset, batch_size=128, shuffle=True)
for index, (xb1, xb2) in enumerate(dataloader):
....
If you want the labels or iterating over more than two datasets just feed them as an argument to the TensorDataset after dataset2.