I am using the dot product as a way to measure the similarly of two facial-model vectors extracted by a ML algorithm (OpenFace in fact).

I would like to convert the L2 norm to a probability U[0,1] in order to compare with other solutions from other providers that map directly to probabilities but in a blackbox fashion.

By probability I mean the probability that the two vectors represent the same person. So an identical image would give a probability of 1; images of the same person would give a high probability; and orthogonal images (different people, or some suitable toy case) would in the limit have such a probability of zero.

I'd like a uniform distribution for comparison with other providers, but this boils down to knowing what the underlying probability distribution of the feature vectors is.

How do I do this?

  1. Rayleigh distribution CDF
  2. Cosine similarity
  3. (1) is the same as (2)
  4. Draw from a simulated distribution
  5. Arbitrarily scale to U[0,1]
  6. Train into the comparison probability space directly (skipping the feature-vector step)
  7. None of the above
  8. Something else?

Some useful links are:

Cosine similarity versus dot product as distance metrics


http://houseofjeff.com/2015/05/10/using-probability-distribution-and-cosine-similarity-to-automatically-detect-data-contents - this one is almost there?

  • $\begingroup$ Also: If the question is unclear, or better suited to a different stackexchange site, please ask for clarification/give constructive feedback rather than simply downvoting. If it's already answered elsewhere please advise. $\endgroup$
    – jtlz2
    Commented Apr 5, 2018 at 7:09
  • 1
    $\begingroup$ I haven't downvoted your question but my question here would be: probability of what? $\endgroup$
    – Konstantin
    Commented Apr 5, 2018 at 9:39
  • $\begingroup$ @Konstantin Thanks for the helpful feedback - I hope my update clarifies? $\endgroup$
    – jtlz2
    Commented Apr 5, 2018 at 9:52
  • $\begingroup$ Cosine similarity seems plausible(+1) It's nice Query. Not sure why downvoting is there.. $\endgroup$
    – Aditya
    Commented Apr 5, 2018 at 10:09

1 Answer 1


I guess you either need to train directly into probability space, or train another model on top of the feature vectors to learn the probability of two vectors belonging to the same person.

All the other metrics you could use on top of the feature vectors are a bit arbitrary, as they were not considered by the cost function used when training the original model.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.