-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MeanIoU differ from custom IOU metrics implementation #20574
Comments
I am reading around and it looks like that approach is more of a global one. Am just heavily surprised that the results might diverge a lot |
Hi @edge7- Thanks for reporting the issue. Can you help me with sample training data where you are able to see diverge in result ? |
Hi, Keras MeanIoU metrics: Do you need a training-set subset? If so, that can be hard to give you, as it's sort of proprietary data. |
Hi, am digging in as it looks like this is not reliable at all.
the scatter is randomly wrong as well. It gets better if one changes the type like this:
|
Hi @edge7 - Can you help me with full sample code with relevant error traceback to dig into the issue more ? |
This is a way to reproduce:
In the first part, you can see the very weird sum, and in the second, the scatter problem. The scatter problem gets solved with: Happy to jump on a call if needed. The files are pretty heavy, but If I subset too much, the error does not show up anymore. |
Last bit from my side: This is slightly different code The output with values = ops.cast(values, dtype=dtype) in metrics utils (current version):
If I change to values = ops.cast(values, dtype="int64") I get:
which means that scatter gets messed up with float. The weird add behaviour is still there, though (which is what matters during training metrics generation).
|
I have done one more step ahead. This is a slightly cleaner code to reproduce. If I run it as it is, I get:
from which we understand that for some reason the keras sum is wrong for element 0,0 in the confusion matrix, but also that even in the second part where the confusion matrix is not added up (as there is just one big slice) is wrong. If I then modify this line
I get:
this implies that the sum issue is still there but at least the "one go" works now as it is identical to SkLearn. I think now @mehtamansi29 you have really all the info I could give you. |
Through this snippet you should be able to reproduce the issue without external data:
This change partially fixes the problem:
There is still something different at the end. The summing part (at the beginning) is very very weird. |
fixed by #20584 |
Hi,
am running a segmentation training process and am using the following function as IoU Custom metrics:
I was expecting that your MeanIoU would be the IoU mean across the classes and also the mean all the training and validation set batches, but it does not seem like that.
example:
given this:
If I run:
and then:
the result is the same.
But If I increase the range they diverge a bit. What is the intuition behind summing confusion matrixes as you do? That is not exactly the average.
In my example, if you increase the range they diverge but not that much, but I see big differences during training:
I am using a custom data generator, if that matters.
Thanks for the clarificaitons
The text was updated successfully, but these errors were encountered: