MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / RandomMappingDataset

Class RandomMappingDataset

codegeex/mindspore/src/sat_dataset.py:175–194  ·  view source on GitHub ↗

Dataset wrapper to randomly mapping indices to original order. Will also enlarge the length

Source from the content-addressed store, hash-verified

173
174
175class 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
197class BlockedSplitDataset(Dataset):

Callers 1

split_train_val_testFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected