Answers.Body: <p>The loss function used is the triplet loss function. 
  <img src="https://i.sstatic.net/7uBuI.png" alt="enter image description here">
  Let me explain it part by part.</p>
  
  <h1>Notation</h1>
  
  <p>The <span class="math-container">$f^a_i$</span> means the <code>anchor</code> input image. The <span class="math-container">$f^p_i$</span> means the <code>postive</code> input image, which corresponds to the same people as the <code>anchor</code> image. The <span class="math-container">$f^n_i$</span> corresponds to the negative sample, which is a different person(input image) then the anchor image. </p>
  
  <h1>The formula explained step by step</h1>
  
  <p>The first part, <span class="math-container">$||f^a_i - f^p_i||^2_2$</span> basically calculates the distance between the <code>anchor</code> image output features and the <code>postive</code> image output features, which you want the distance to be as small as possible as the input is the same person. For the second part, <span class="math-container">$||f^a_i - f^n_i||^2_2$</span> , it calculates the distance of the output features of the <code>anchor</code> image and the <code>negative</code> image. You wnat the distance to be as large as possible as they are not the same person. Finally, the <span class="math-container">$\alpha$</span> term is a constant(hyperparameter) that adds to the loss to prevent negative loss. </p>
  
  <h1>How it works</h1>
  
  <p>The loss function optimizes for the largest distance between the anchor and negative sample and the smallest distance of the positive and anchor sample. It cleverly combines both metrics into one loss function. It can optimize for both case simultaneously in one loss function. If there is no negative sample, the model will not be able to differciate different person and vice versa.</p>
  
  <p>Hope I can help you and have a nice day!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-10T17:07:05.737Z
Answers.Text: The question which i am linked ,what i want to ask is :Suppose i trained the images of two people say Bob , Thomas  .When i run the algorithm to detect the face of a totally different person from these two say John , then John is recognized as Bob or Thomas.How to avoid this ?
Answers.UserDisplayName: TheReal__Mike
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-11T06:26:42.010Z
Answers.Text: If you know how percentage is calculated , then can you explain it using an example (using image matrix) .You can explain this in this answer or in https://ai.stackexchange.com/questions/16175/three-step-threshold-in-facenet-model-of-face-recogniton or i can ask new question if you want
Answers.UserDisplayName: TheReal__Mike
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-06T15:47:28.690Z
Answers.LastActivityDate: 2019-11-11T08:49:18.283Z
Answers.LastEditDate: 2019-11-11T08:49:18.283Z
Answers.UserDisplayName: Clement
Body: <p>The <a href="https://arxiv.org/abs/1503.03832" rel="nofollow noreferrer">FaceNet model</a> returns the loss of the predictions and ground-truth classes. How is this loss calculated?</p>
  
Tags: <neural-networks><objective-functions><facial-recognition>
Title: What is the formula used to calculate the loss in the FaceNet model?
UserDisplayName: TheReal__Mike
ThreadText: # What is the formula used to calculate the loss in the FaceNet model?
  
  (Asked by: username_0 on 2019-11-06)
  
  The [FaceNet model](https://arxiv.org/abs/1503.03832) returns the loss of the predictions and ground-truth classes. How is this loss calculated?
  
  **Tags:** neural-networks, objective-functions, facial-recognition
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-06. Score: 6 | Accepted answer
  
  The loss function used is the triplet loss function.
  ![enter image description here](https://i.sstatic.net/7uBuI.png)
  Let me explain it part by part.
  
  # Notation
  
  The $f^a\_i$ means the `anchor` input image. The $f^p\_i$ means the `postive` input image, which corresponds to the same people as the `anchor` image. The $f^n\_i$ corresponds to the negative sample, which is a different person(input image) then the anchor image.
  
  # The formula explained step by step
  
  The first part, $||f^a\_i - f^p\_i||^2\_2$ basically calculates the distance between the `anchor` image output features and the `postive` image output features, which you want the distance to be as small as possible as the input is the same person. For the second part, $||f^a\_i - f^n\_i||^2\_2$ , it calculates the distance of the output features of the `anchor` image and the `negative` image. You wnat the distance to be as large as possible as they are not the same person. Finally, the $\alpha$ term is a constant(hyperparameter) that adds to the loss to prevent negative loss.
  
  # How it works
  
  The loss function optimizes for the largest distance between the anchor and negative sample and the smallest distance of the positive and anchor sample. It cleverly combines both metrics into one loss function. It can optimize for both case simultaneously in one loss function. If there is no negative sample, the model will not be able to differciate different person and vice versa.
  
  Hope I can help you and have a nice day!
  
  > **Comments:**
  > **username_0**: The question which i am linked ,what i want to ask is :Suppose i trained the images of two people say Bob , Thomas  .When i run the algorithm to detect the face of a totally different person from these two say John , then John is recognized as Bob or Thomas.How to avoid this ?  
  > **username_0**: If you know how percentage is calculated , then can you explain it using an example (using image matrix) .You can explain this in this answer or in https://ai.stackexchange.com/questions/16175/three-step-threshold-in-facenet-model-of-face-recogniton or i can ask new question if you want  
  
  ---
  
  