MCPcopy Create free account
hub / github.com/NineAbyss/ZeroG / OneShotDataset

Class OneShotDataset

code/utils.py:299–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297 return x
298
299class OneShotDataset(Dataset):
300 def __init__(self, original_dataset):
301 self.data = []
302 self.labels = []
303 class_samples = {}
304
305 for i in range(len(original_dataset)):
306 data = original_dataset.data.x[i]
307 label = original_dataset.data.y[i].item()
308 if label not in class_samples:
309 class_samples[label] = data
310 self.labels.append(label)
311
312 self.data = list(class_samples.values())
313
314 def __len__(self):
315 return len(self.data)
316
317 def __getitem__(self, idx):
318 return self.data[idx], self.labels[idx]
319
320class AlignDataset(Dataset):
321 def __init__(self, features, label_emb, label):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected