Use DataLoader with a tuple index

Hello, I am trying to use my DataLoader with a tuple index dataset. I need this because each index refers to a specific coordinate in a huge image, therefore I keep it as the index. However, when I am trying to load each image from the the Dataloader, I get the following error:

error list indices must be integers or slices, not tuple (37, 71)

with torch.no_grad():
        for batch in data_loader:
            data, _, idx = batch
            logits = model(data.to(device))
            probabilities = F.softmax(logits, dim=1)

This is how, I create the dataloader:

pool_loader = DataLoader(dataset, batch_size=batch_size, num_workers=num_workers,
                                         sampler=SubsetRandomSampler(pool_idx))

Is there any way to use the Dataloader using a tuple index?

1 Like