MCPcopy Create free account
hub / github.com/TPCD/DCCL / subsample_classes

Function subsample_classes

data/pets.py:165–178  ·  view source on GitHub ↗
(dataset, include_classes=range(60))

Source from the content-addressed store, hash-verified

163 return dataset
164
165def subsample_classes(dataset, include_classes=range(60)):
166
167 cls_idxs = [i for i, (p, t) in enumerate(dataset.samples) if t in include_classes] # 1885
168
169 # TODO: Don't transform targets for now
170 target_xform_dict = {}
171 for i, k in enumerate(include_classes):
172 target_xform_dict[k] = i
173
174 dataset = subsample_dataset(dataset, cls_idxs)
175
176 dataset.target_transform = lambda x: target_xform_dict[x]
177
178 return dataset
179
180def get_train_val_indices(train_dataset, val_split=0.2):
181

Callers 1

get_pets_datasetsFunction · 0.70

Calls 1

subsample_datasetFunction · 0.70

Tested by

no test coverage detected