MNIST나 CIFAR-10 등과 같이 10개의 Class로 분류된 데이터셋을 2개(또는 5개)의 Class로 다시 분류하고 싶으신 것이 맞을까요?
그렇다면, Dataset class에서 label을 반환할 때 위 표의 Semantics와 같은 기준으로 다시 label을 변환하도록 하면 어떨까요?
def __getitem__(self, index: int) -> Tuple[Any, Any]:
"""
Args:
index (int): Index
Returns:
tuple: (image, target) where target is index of the target class.
"""
img, target = self.data[index], int(self.targets[index])
# doing this so that it is consistent with all other datasets
# to return a PIL Image
img = Image.fromarray(img.numpy(), mode="L")
if self.transform is not None:
img = self.transform(img)
if self.target_transform is not None:
target = self.target_transform(target)
return img, target