I want to generate a random subset from DataLoader.
I have the following implementation:
train_indices = torch.LongTensor(args.train_set_size).random_(0, totalNumInTrainSet)
train_loader = torch.utils.data.DataLoader(
            datasets.MNIST('../data', train=True, download=True,
                           transform=transforms.Compose([
                               transforms.ToTensor(),
                               transforms.Normalize((0.1307,), (0.3081,),
                                                    )
                           ])),
            batch_size=args.batch_size, sampler=SubsetRandomSampler(train_indices), ** kwargs)

This works, however generating the train indices results in duplicates, I want all random numbers generated to be unique. How would I do this efficiently ?