pytorch-nested-unet
pytorch-nested-unet copied to clipboard
Incorrect IOU definition
The current IOU implementation has calculated the union and intersection over samples in a mini-batch, then it has calculated the IOU score. But I think IOU should be calculated per sample then take the mean over the samples in the mini-batch.
I think the following code is correct when the number of classes is 1:
intersection = (output_ & target_).sum(axis=(1, 2, 3))
union = (output_ | target_).sum(axis=(1, 2, 3))
return (intersection + smooth) / (union + smooth).mean()
Hi, will that IOU score higher?
@zhou-rui1 I don't think so. The current implementation might output a much higher score.