Display misclassified images in pytorch
I'm new to pytorch and numpy so this may be a dumb question. I'd like to see some images misclassified by my net, with the correct label and the predicted label. Here is my code
valid_and_test_set = torchvision.datasets.MNIST(&quot;./mnist&quot;, train=False, download=True)
dataset_valid, dataset_test = torch.utils.data.random_split(valid_and_test_set,[5000, 5000])
dataset_test.dataset.transform = transform #transform is composed by unsqueeze, normalize, view and gaussian noise with randn
dataset_test.dataset.target_transform = OneHot() #OneHot return the label
dataloader_test = torch.utils.data.DataLoader(dataset_test.dataset, batch_size=5000, num_workers=num_workers, pin_memory=True)

def test(dataset, dataloader):
    net.eval()  
    with torch.no_grad():
        for batch in dataloader:
            inputs = batch[0]
            inputs = inputs.to(device, non_blocking=True)
            outputs = net(inputs)
            predictions = torch.argmax(outputs, dim=1)
            return predictions

Thank you in advance

There's atleast two ways you could do this in.
One is, to store the images which were misclassified during evaluation(running through the test data) and plot those. This is shown here
Another way is to make use of TensorBoard. This is quite elegant in my opinion, and you can find a comprehensive guide for it here
