HarDNet was trained to perform semantic segmentation of images. Increase of a meandice implies that the model quality improved.

    def meandice(pred, mask):
        weit = 1 + 5 * torch.abs(F.avg_pool2d(mask, kernel_size=31, stride=1, padding=15) - mask)
        wbce = F.binary_cross_entropy_with_logits(pred, mask, reduce='none')
        wbce = (weit * wbce).sum(dim=(2, 3)) / weit.sum(dim=(2, 3))

        pred = torch.sigmoid(pred)
        inter = ((pred * mask) * weit).sum(dim=(2, 3))
        union = ((pred + mask) * weit).sum(dim=(2, 3))
        wiou = 1 - (inter + 1) / (union - inter + 1)

        return (wbce + wiou).mean()

This is the code they are using. But the increase in wbce (binary cross entropy) implies that the predictions are getting worse. Same is true for wiou which 1 minus the Intersection over the Union. The weit is a weighting coefficient that increases the loss cost near the boundaries.

Should this function be minimized during the optimization?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.