Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About precision and recall during training #189

Open
Ghost0405 opened this issue Apr 4, 2023 · 1 comment
Open

About precision and recall during training #189

Ghost0405 opened this issue Apr 4, 2023 · 1 comment

Comments

@Ghost0405
Copy link

When I am training model = 1, these two values are always 1, is this correct?Which loss in the logs_edge.dat file should you pay more attention to when training model = 1?
image

@m-elhussieny
Copy link

class EdgeAccuracy(nn.Module):
    """
    Measures the accuracy of the edge map
    """
    def __init__(self, threshold=0.5):
        super(EdgeAccuracy, self).__init__()
        self.threshold = threshold

    def __call__(self, inputs, outputs):
        labels = (inputs > self.threshold)
        outputs = (outputs > self.threshold)

        relevant = torch.sum(labels.float())
        selected = torch.sum(outputs.float())

        if relevant == 0 and selected == 0:
            return torch.tensor(1), torch.tensor(1)

        true_positive = ((outputs == labels) * labels).float()
        recall = torch.sum(true_positive) / (relevant + 1e-8)
        precision = torch.sum(true_positive) / (selected + 1e-8)

        return precision, recall

according to this the relevant and selective must have a value greater than zero to get result. I thing the edge you have generated had values below threshold. make sure edges to have only values of 0 and 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants