@ptrblck I did use the scikit-learn implementation to calculate the confusion matrix. The snippet is like this.

    with torch.no_grad():
        for i, data in enumerate(test_loader, 0):
            # get the inputs
            t_image, mask = data
            t_image, mask = Variable(t_image.to(device)), Variable(mask.to(device))
        
            output = model(t_image)
            pred = torch.exp(output)
            conf_matrix = confusion_matrix(pred, mask)
            print(conf_matrix)

I am wondering why I am getting this error , what do you think? is it related to the shape of pred or input?
  File "C:\Users\Neda\Anaconda3\lib\site-packages\sklearn\metrics\classification.py", line 88, in _check_targets
    raise ValueError("{0} is not supported".format(y_type))
ValueError: unknown is not supported