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

Selecting semi-hard examples, possible bug? #37

Open
guyov1 opened this issue Feb 21, 2017 · 0 comments
Open

Selecting semi-hard examples, possible bug? #37

guyov1 opened this issue Feb 21, 2017 · 0 comments

Comments

@guyov1
Copy link

guyov1 commented Feb 21, 2017

Hello,
In the tripletselect layer, we aim to choose semi-hard negative examples. meaning, negative examples that are within a margin alpha comparing to the positive example.
In your custom layer, you sort both a_p and a_n examples so that the highest distance is first.
Don't we want the highest a_p distance and the smallest a_n distance so they might violate the semi-hard definition?

The following code with my suggested fix:

` archor_feature = bottom[0].data[0]

    for i in range(self.triplet):

        positive_feature = bottom[0].data[i+self.triplet]
        a_p = archor_feature - positive_feature
        ap = np.dot(a_p,a_p)
        aps[i+self.triplet] = ap
        aps = sorted(aps.items(), key = lambda d: d[1], reverse = True)

    for i in range(self.triplet):

        negative_feature = bottom[0].data[i+self.triplet*2]
        a_n = archor_feature - negative_feature
        an = np.dot(a_n,a_n)
        ans[i+self.triplet*2] = an
    #ans = sorted(ans.items(), key = lambda d: d[1], reverse = True)  # guyn - seems to me like a bug, we want the lowest distance to be first
    ans = sorted(ans.items(), key = lambda d: d[1], reverse = False)`

What do you think?
Guy

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

1 participant