I want to create a subset of a dataset which has its own indexing, i.e. following range(len(subset))
.
When I create a subset with provided utility and iterate over the subset then the indexing followed is that of the original dataset.
n= len(dataset)
indices = np.random.choice(n, int(n*0.5))
subset= torch.utils.data.Subset(dataset, indices)
loader = DataLoader(subset, batch_size=100, shuffle=True, num_workers=0)
for batchid, (inputs, labels, index) in enumerate( iter(loader)):
assert(np.max(np.array(index)) < len(subset)) # this assert is invoked