Dataset wrapper to randomly mapping indices to original order. Will also enlarge the length
| 173 | |
| 174 | |
| 175 | class RandomMappingDataset(Dataset): |
| 176 | """ |
| 177 | Dataset wrapper to randomly mapping indices to original order. |
| 178 | Will also enlarge the length |
| 179 | """ |
| 180 | |
| 181 | def __init__(self, ds): |
| 182 | self.wrapped_data = ds |
| 183 | self.index_mapping = np.random.permutation(np.arange(len(ds))) |
| 184 | |
| 185 | def __len__(self): |
| 186 | return len(self.wrapped_data) |
| 187 | |
| 188 | def __getitem__(self, index): |
| 189 | # rng = random.Random(index) |
| 190 | # rng = np.random.RandomState( |
| 191 | # seed=[rng.randint(0, 2 ** 32 - 1) for _ in range(16)] |
| 192 | # ) |
| 193 | # index = rng.randint(len(self.wrapped_data)) |
| 194 | return self.wrapped_data[self.index_mapping[index]] |
| 195 | |
| 196 | |
| 197 | class BlockedSplitDataset(Dataset): |
no outgoing calls
no test coverage detected