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

Function subsample_classes

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

Source from the content-addressed store, hash-verified

176 return dataset
177
178def subsample_classes(dataset, include_classes=range(60)):
179
180 cls_idxs = [i for i, (p, t) in enumerate(dataset.samples) if t in include_classes] # 1885
181
182 # TODO: Don't transform targets for now
183 target_xform_dict = {}
184 for i, k in enumerate(include_classes):
185 target_xform_dict[k] = i
186
187 dataset = subsample_dataset(dataset, cls_idxs)
188
189 dataset.target_transform = lambda x: target_xform_dict[x]
190
191 return dataset
192
193def get_train_val_indices(train_dataset, val_split=0.2):
194

Callers 1

get_flower_datasetsFunction · 0.70

Calls 1

subsample_datasetFunction · 0.70

Tested by

no test coverage detected