def forward(self, input, target):
    bce = F.binary_cross_entropy_with_logits(input, target)
    smooth = 1e-05
    input = F.sigmoid(input)
    num = target.size(0)
    input = input.view(num, (- 1))
    target = target.view(num, (- 1))
    intersection = (input * target)
    dice = (((2.0 * intersection.sum(1)) + smooth) / ((input.sum(1) + target.sum(1)) + smooth))
    dice = (1 - (dice.sum() / num))
    return ((0.5 * bce) + (0.5 * dice))
def forward(self, input, target):
    bce = F.binary_cross_entropy_with_logits(input, target)
    smooth = 1e-05
    input = F.sigmoid(input)
    num = target.size(0)
    input = input.view(num, (- 1))
    target = target.view(num, (- 1))
    intersection = (input * target)
    dice = (((2.0 * intersection.sum(1)) + smooth) / ((input.sum(1) + target.sum(1)) + smooth))
    dice = (1 - (dice.sum() / num))
    return ((0.5 * bce) + (0.5 * dice))