Confusion Matrix Metric in Supervised Evaluator #3549
Replies: 4 comments 7 replies
-
Hi @skrishnanv , Seems the issue is your pred and label are not on the same device. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi @skrishnanv @Nic-Ma, |
Beta Was this translation helpful? Give feedback.
-
I couldn't make a complete example. However, what I found is that if I
detach the data structures during decollate, it seems to work fine. I will
try to get an example soon.
…On Thu, 6 Jan, 2022, 9:07 pm Fares Ouadahi, ***@***.***> wrote:
Hi @skrishnanv <https://github.com/skrishnanv> @Nic-Ma
<https://github.com/Nic-Ma>,
I have the same problem with the ConfusionMatrix handler from Monai, even
when forcing the device to be on the GPU, I get the same RuntimeError about
the tensors being on the cpu and on the gpu. It seems to work only when the
CPU is used.
—
Reply to this email directly, view it on GitHub
<#3549 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALAFBNNUIOOLDOC6IEQ72WDUUWZK3ANCNFSM5K4KN7MA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I mean whatever you have written below; no changes. One change you can
check is to use detach=False in decollate_batch. I seem to recall it
worked(i do not know why, if it does for you).
…On Thu, Jan 6, 2022 at 9:30 PM Fares Ouadahi ***@***.***> wrote:
Hi @skrishnanv <https://github.com/skrishnanv>,
Thank you for your answer.
I am already using decollate_batch in the evaluator like this:
evaluator_val = create_supervised_evaluator(net, val_metrics, device, non_blocking=True,
output_transform=lambda x, y, y_pred: ([post_pred(i) for i in decollate_batch(y_pred)], [gt_post(i) for i in decollate_batch(y)]),
prepare_batch=prepare_batch)
with post_pred and gt_post including the post processing transforms.
Do you mean you used the Decollated transform ?
—
Reply to this email directly, view it on GitHub
<#3549 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALAFBNOOLNPSQADGS6RTSDTUUW4CDANCNFSM5K4KN7MA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I am trying to compute the confusion matrix for the evaluation. In the sample code from various example
where
If the line containing CFM is commented out, all works fine. However, if i uncomment the CFM,
the error I get is
File "C:\Users\Krishnan\anaconda3\envs\pytorch\lib\site-packages\monai\metrics\confusion_matrix.py", line 102, in _compute_tensor
return get_confusion_matrix(
File "C:\Users\Krishnan\anaconda3\envs\pytorch\lib\site-packages\monai\metrics\confusion_matrix.py", line 173, in get_confusion_matrix
tp = ((y_pred + y) == 2).float()
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
I do not understand how this is possible since the same output_transform is used for ROCAUC and ConfusionMatrix. I do not want to compute the matrix every validation cycle but I am not able to understand whats wrong in the code. I tried using ignite metrics but that is leading to another set of errors and is not relevant here. I plan use sklearn on the ypred and y but I was wondering what is wrong here.
Any help is appreciated.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions