Hello all,
I am trying to split class labels 0 to 9 of the Tiny-imagenet dataset so I tried the following code
train_dataset = TinyImageNet('tiny-imagenet-200', 'train', transform=transform)
train_labels_np=np.array(list(train_dataset.labels.values()))
train_indexes=np.where((train_labels_np==0)|(train_labels_np==1)|
(train_labels_np==2)|(train_labels_np==3)|
(train_labels_np==4)|(train_labels_np==5)|
(train_labels_np==6)|(train_labels_np==7)|
(train_labels_np==8)|(train_labels_np==9))[0]
np.random.shuffle(train_indexes) #Shuffle
training_split_indexes = train_indexes[0:2048] #select some examples
sampler_train= torch.utils.data.SubsetRandomSampler(training_split_indexes)
train_set = torch.utils.data.DataLoader(train_dataset, batch_size=args.train_batch_size, sampler=sampler_train, **kwargs)
test_dataset = TinyImageNet('tiny-imagenet-200', 'val', transform=transform)
test_labels_np=np.array(list(test_dataset.labels.values()))
test_indexes=np.where((test_labels_np==0)|(test_labels_np==1)|
(test_labels_np==2)|(test_labels_np==3)|
(test_labels_np==4)|(test_labels_np==5)|
(test_labels_np==6)|(test_labels_np==7)|
(test_labels_np==8)|(test_labels_np==9))[0]
sampler_test = torch.utils.data.SubsetRandomSampler(test_indexes)
test_set = torch.utils.data.DataLoader(test_dataset, batch_size=args.test_batch_size, shuffle=False, sampler=sampler_test, **kwargs)
Error IndexError: Target 68 is out of bounds.
has occurred from
loss= self.cross_entropy_loss(output, target)
in test function.
how can I handle it?
thanks.