Hi,
I have problem with IndexError on evaluation model. I use transfer learning on VGG16 and I replaced last layer for nn.Linear(4096, 264), because I have 264 classes.
I got IndexError: index 43352 is out of bounds for dimension 0 with size 32218
My length of test_dataset is 32218.
Here is my code of splitting into train and test set:
train_size = int(0.8 * len(mvc_dataset))
test_size = len(mvc_dataset) - train_size
train_dataset, test_dataset = torch.utils.data.random_split(mvc_dataset, [train_size, test_size])


num_train = len(train_dataset)
indices = list(range(num_train))
split = int(np.floor(0.20 * num_train))
np.random.shuffle(indices)

train_idx, test_idx = indices[split:], indices[:split]
train_sampler = SubsetRandomSampler(train_idx)
test_sampler = SubsetRandomSampler(test_idx)


train_loader = nc.SafeDataLoader(train_dataset,
                          sampler=train_sampler, batch_size=1)
test_loader = nc.SafeDataLoader(test_dataset,
                         sampler=test_sampler, batch_size=1)

And when I got error:
    for images, annotations in test_loader:
        images = Variable(images.cuda() if torch.cuda.is_available() else images, requires_grad=True)
        annotations = Variable(annotations.cuda() if torch.cuda.is_available() else annotations)

        outputs = model(images)
        _, predicted = torch.max(outputs)
        total += annotations.size[0]
        correct += (predicted == annotations).sum().item()

Any know, what should I do in this situation?