I am getting a noisy classified image inspite of getting test accuracy of 99 percent

Dear friends, I am getting a noisy classified image inspite of getting test accuracy of 99 percent. I am using the following function for obtaining the classification map.

def classified_pixels(FPatches,gPatches,g):
  data_test=MyDataset(FPatches, gPatches)
  test_loader = torch.utils.data.DataLoader(data_test,batch_size=10,shuffle=False, num_workers=2)
  with torch.no_grad():
    correct = 0
    total = 0
    for images, labels in test_loader:
      images = images.to(device)
      labels = labels.to(device)
      outputs = model(images)
      _, predicted = torch.max(outputs.data, 1)
      total += labels.size(0)
      correct += (predicted == labels).sum().item()
  for arr in classification_map:

  outputs = np.zeros((height,width))
  for i in range(height):
    for j in range(width):
       target = g[i][j]
       if target == 0 :
       else :
  return classification_map,outputs

If you add more context to your question then people who are not very familiar with the exact setting of your problem, may also be able to help you. This could increase the chances of you getting useful inputs from the forum.

Examples of more context include: What is the problem that you are trying to solve? What does the input look like? What is the output that you expect? What does your model look like? And so on.

@gphilip, I have performed pixel classification of Hyperspectral Image using the above mentioned model. I have extracted the patches mentioned as FPatches around the neighbourhood of the pixel and consider them as samples. The label of the center pixel of the FPatch is considered as the label for the entire FPatch. The model is trained using training samples and tested using test samples. Test accuracy is more than 99 percent. For obtaining the classification map I have taken the entire FPatches and predicted the labels using the same trained model. Finally I have converted the predicted classes into array to get the classification map. One important thing to mention is that the groundtruth contains background pixels denoted as 0 so when the classification map array is generated we will keep those classes as zero.

Thank you for the details.

I don’t have enough knowledge in your domain to answer your question; let us hope others can help you figure this out.