Hi.
In the notebook below I’ve created a Deep Learning Model in Pytorch and trained and tested it.
I want to save the instances of the test image data and the test image labels which and predicted test labels which came incorrect running it on the test set.
I have been trying to implement it using the for loops near the end of the Jupyter Notebook using :
correct = 0
total = 0

incorr_X = []
incorr_y = []
incorr_argmax = []

with torch.no_grad():
    for data in testset:
        X, y = data
        output = net(X.view(-1,784))
        #print(output)
        for idx, i in enumerate(output):
            #print(torch.argmax(i), y[idx])
            if torch.argmax(i) == y[idx]:
                correct += 1
            else:
                incorr_X.append(X)
                incorr_y.append(y)
                incorr_argmax.append(torch.argmax(i))
            total += 1

print("Accuracy: ", round(correct/total, 3))
Is this the correct approach to get the incorrectly predicted image, label and predicted label?
How do I access the corresponding images, labels and predicted labels?
I have written some implementations in the Notebook, but they seem to not be working.
Any help will be greatly appreciated.
Thank you!!!
Link to Notebook:

  
      github.com
  
  
    ScarletMcLearn/DataScience/blob/master/Deep Learning/Image Classification/PyTorch - Fashion - MNIST - 3.ipynb 24
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torchvision\n",
    "from torchvision import transforms, datasets\n",
    "\n",
    "import torch.nn as nn\n",
    "import torch.nn.functional as F\n",
    "import torch.optim as optim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,


  This file has been truncated. show original