Hi Sarmad!



 Sarmad_GTU:

can I use this code from the semantic segmentation PyTorch model  to calculate the IOU


I haven’t looked at your code (After all, who knows what _threshold()
might do?), but if your intersection-over-union function does use a
“threshold for outputs binarization,” it will not be (usefully) differentiable,
and therefore can’t be used as a loss function for backpropagation and
training.  (CrossEntropyLoss is a good loss function to start with for
semantic segmentation.)  IoU (even with thresholding) is, of course, a
perfectly reasonable evaluation metric.
Best.
K. Frank