Beispiel #1
0
def calc_acc(input: torch.Tensor, target: torch.Tensor):
    input[input >= 0.7] = 1
    input[input < 0.7] = 0
    input = input.cpu().int()
    target = target.cpu().int()
    tot = target.sum().item()
    P = input.sum().item()
    cnt = (input.__and__(target)).sum().item()
    R = cnt / tot
    P = cnt / (P + 0.001)
    F1 = 2 * P * R / (P + R + 0.001)
    return F1