FaceNet: Face Recognition and Clustering

A Unified Embedding for Face Recognition and Clustering

Paper: FaceNet: A Unified Embedding for Face Recognition and Clustering
Authors: Florian Schroff (Google), Dimitry Kalenichenko (Google) and James Philbin (Google)
Area: Computer Vision, Clustering, Classification, Deep Learning
Year: 2015
Highlighted Paper

Background:

  • Euclidean space, distance and vector norms
  • Nearest neighbor/k-means/clustering
  • CNNs: Stanford's CS231N course notes, Deep learning book chapter 9
  • Important architectures for this paper:
    1. Zeiler&Fergus
    2. Google LeNet Inception Model
  • Key Contributions:

    1. Learns a mapping from face images to a compact Euclidean space where distances directly correspond to measure of face similarity. The method uses a CNN to directly optimize the embedding itself.
    2. To train - use triplets of roughly aligned matching/non-matching face patches generated using an online triplet mining method.

    Why is this novel? Unlike previous approaches where a final classification layer is used to predict the class, here we are leaning an embedding which can then be used for various classification purposes.

    Model Triplet Loss:
    $$\sum_{i}^{N}[\lVert f(x_{i}^{a}) - f(x_{i}^{p}) \rVert_{2}^{2} - \lVert f(x_{i}^{a}) - f(x_{i}^{n}) \rVert_{2}^{2} + \alpha)]$$ \(a\) is the anchor, \(p\) is a positive and \(n\) is a negative. You essentially want to optimize for making the positive closer to the anchor than the negative.

    Triplet Selection:
    We focus on the online generation and use large mini-batches in the order of a few thousand exemplars and only compute the \(argmin\) and \(argmax\) within that mini-batch.

    CNN Architecturse:
    Existing architectures - Inception model and the Zeiler&Fergus model.

    Some implementations:
    tbmoon's implementation using PyTorch
    timseler's implementation

    Datasets
    Labeled Faces in the Wild (LFW) courtsey of UMass
    YouTube Faces DB

    Sequence to Sequence Learning with Neural Networks

    Using LSTMs for general sequence-to-sequence problems

    Deep neural networks are powerful machine learning models that achieve excellent performance on difficult problems. If there exists a parameter setting of a large DNN that achieves good results, supervised backpropagation will find these parameters and solve the problem.

    The Problem

    Many important problems are best expressed with sequences whose lengths are not known a-priori. For example, speech recognition and machine translation are sequential problems. Likewise, question-answering can also be seen as mapping a sequence of words representing the question to a sequence of words representing the answer.

    The Approach

    The core idea is to use one LSTM to read the input sequence, one timestep at a time, to obtain a large fixed-dimensional vector representation, and then use another LSTM to extract the output sequence from that vector.

    The second LSTM is essentially a recurrent neural network language model, except that it is conditioned on the input sequence.

    Key Properties

    • The LSTM learns to map an input sequence of variable length into a fixed-dimensional vector representation
    • The encoder-decoder architecture separates input processing from output generation
    • Attention mechanisms (in later work) address limitations of fixed-size representations

    Related Work

    • Kalchbrenner and Blunsom, "Recurrent continuous translation models" (EMNLP, 2013)
    • Cho et al., "Learning phrase representations using RNN encoder-decoder for statistical machine translation" (2014)

    Beam Search Algorithm

    A heuristic search algorithm for finding optimal sequences

    Overview

    Beam search is a heuristic search algorithm commonly used in sequence-to-sequence models for tasks like machine translation, speech recognition, and text generation. It explores a graph by expanding the most promising nodes while keeping only a limited number of candidates at each level.

    How It Works

    Beam search uses breadth-first search to build its search tree. At each level:

    1. Generate all successors of the states at the current level
    2. Sort them in increasing order of heuristic cost
    3. Keep only the top \(\beta\) states (the beam width)
    4. Expand only those states in the next iteration

    The greater the beam width, the fewer states are pruned. With \(\beta = 1\), beam search becomes greedy search. With \(\beta = \infty\), it becomes exhaustive breadth-first search.

    Why Use Beam Search?

    Beam search maintains tractability in large systems with insufficient memory to store the entire search tree. It provides a balance between:

    • Greedy search: Fast but may miss optimal solutions
    • Exhaustive search: Optimal but computationally infeasible

    Applications

    • Neural Machine Translation: Finding the most likely translation
    • Speech Recognition: Decoding audio to text
    • Image Captioning: Generating descriptions for images
    • Text Generation: Producing coherent sequences in LLMs

    Limitations

    Beam search is not guaranteed to find the optimal solution since it prunes the search space. The choice of beam width \(\beta\) is a trade-off between search quality and computational cost.