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

tipletselectlayer - computing the distance against the anchor image #51

Open
identidata opened this issue Aug 29, 2017 · 2 comments
Open

Comments

@identidata
Copy link

identidata commented Aug 29, 2017

When you calculate the dot product between the anchor feature and all positive features, you are calculating the product between the first image of anchor layer (total 10 images, using a batch of 30 as in your example) and all images of the positive layer.

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

You repeat a similar procedure between the first image in the anchor layer and all images in the negative layer:

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

I am not sure if there is a away around it, but what are all the other images in the anchor layer used for? (in your example 9 images, from image 1 to image 9)? nothing?

@PramuPerera
Copy link

If there are 9 images, first three (self.triplet==3 here) are used as anchors (anchor is given by the positive_feature variable).
Note that positive feature is changing at every iteration.
a_p = archor_feature - positive_feature subtracts the positive feature from the whole batch.
ap = np.dot(a_p,a_p) calculates the l2 distance.

@gitrobin
Copy link

but the second and third anchors are useless?

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

3 participants