Hi all, I want to create a customized dataloader that will be do as follows:

For each epoch, select a position in a given list without replacement. So, if the list has length is 10, then after 10 epochs, all positions in the list are selected

import torch.utils.data as data

class My_Dataset(data.Dataset):

    def __init__(self, data_list):
        self.data_list = data_list
    def __getitem__(self, index):
        
        position = np.random.randint (0, len(self.data_list))
        return self.data_list[position]

    def __len__(self):
        return len(self.data_list)


For example, the data_list=[1,4,5,7,8], if the first epoch selects position =4, then second epoch should select another position except 4 (because it selected in first epoch), and so on. We will permute the list when epoch bigger than data_list size