Hello Deb -



 Deb_Prakash_Chatterj:

Hey guys, I am making a ROC graph for my multi-class classification problem.
…
Now it is telling that -
Automatically created module for IPython interactive environment
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-34-bda71c8fb3a6> in <module>()
     17 roc_auc = dict()
     18 for i in range(nb_classes):
---> 19    fpr[i], tpr[i], _ = roc_curve(labels[:, i], prediction[:, i]) # here change y_test to labels
     20    roc_auc[i] = auc(fpr[i], tpr[i])
     21 # Compute micro-average ROC curve and ROC area

IndexError: too many indices for tensor of dimension 1

I have checked about shape of prediction and labels. Those are both torch.Size([32]).
I wonder why it is throwing an error. Can anyone of you help? Thanks.


In prediction[:, i] you are passing prediction two indices.
(":" counts as an index.)  If prediction.shape is indeed
torch.Size([32]) (a one-index tensor) you are indeed passing
it “too many indices.”
Best.
K. Frank