Ah OK.
I guess you want to use the same data in your Dataset?
If so, you could just fake a new length and use a modulo operation in index to avoid an out of range error:
class BarDataset(Dataset):
def __init__(self):
self.data = list(np.random.rand(9))
pass
def __getitem__(self, idx):
# some ops
idx = idx % len(self.data)
out = np.array([self.data[idx] * 2, self.data[idx] * 3])
return out
def __len__(self):
return 2 * len(self.data)