C4W4L05 Face Verification

Face verification uses Siamese networks with tied weights to compute embeddings from two images, then feeds their differences into a sigmoid classifier to predict same or different person. Pre-computing embeddings for database images avoids redundant computation at deployment.
Questions this video answers
1 if images are the same person; 0 if they are different persons.
Maybe 128-dimensional embeddings (illustrative).
Element-wise absolute differences of the two encodings (128 features); a chi-square-style variant (squared difference divided by sum) is also mentioned.
Chapters
The triplet loss is one good way to learn the parameters of a convnet for face recognition. There's another way to learn these parameters. Let me show you how face recognition can also be posed as a straight binary classification problem. Another way to train a neural network is to take this pair of neural networks, to take this Siamese network and have them both compute these embeddings, maybe 128 dimensional embeddings, maybe even higher dimensional, and and then have these be input to a logistic regression unit to then just make a prediction where the target output will be 1 if both of these are the same persons, and 0 if both of these are of different persons. So this is a way to treat face recognition just as a binary classification problem. Um, and this is an alternative to the triplet loss for training a system like this. Now, what does this final logistic regression unit actually do? The output Y hat will be, let's say, a sigmoid function applied to some set of features. But rather than just feeding in these encodings, what you can do is take the differences between the encodings. So let me show you what I mean. Let's say I write a sum over k equals 1 to 128 of, let's say the absolute value taken element wise between the two different encodings. So let me just finish writing this out and then we'll see what this means. So in this notation, F of xi is the encoding of the image xi. And this subscript k means to just select out the k th component of this vector. So this is taking the element wise difference in absolute values between these two encodings. And what you might do is think of these 128 numbers as features that you then feed into logistic regression. And your final logistic regression can have additional parameters WI and B, similar to a normal logistic regression unit. And you would train a appropriate weighting on these 128 features in order to predict whether or not these two images are of the same person or of different persons. So this would be one pretty reasonable way to learn to predict 0 or 1 whether these are the same person or different persons. And there are a few other variations on how you can compute this formula that I had underlined in green. For example, another formula could be this, okay, minus F of xj k squared divided by F of x I plus F of xj. Okay? This is sometimes called the chi square formula. This is the Greek Alphabet chi, but this is sometimes called the chi square similarity. And this and other variations are explored and this and other variations are explored in this deep phase paper, which I had referenced earlier as well. But so in this learning formulation, the input is a pair of images. So this is really your training input X, and the output y is either 0 or 1, depending on whether you're inputting a pair of similar or dissimilar images. And same as before, you're training a Siamese network. So that means that this neural network up here has parameters that are the same or they're really tied to the parameters in this lower neural network. And this system can work pretty well as well. Um, lastly, I just want to mention one computational trick that can help your deployment significantly, which is that if this is the new image, so this is an employee walking in, hoping that the turnstile, the doorway will open for them, and if this is from your database image, then instead of having to compute this set of features, then instead of having to compute this embedding every single time, what you can do is actually pre compute that. So when the new employee walks in, what you can do is use this upper convnet to compute that encoding and use it, then compare it to your pre computed encoding and then use that to make a prediction Y hat. So because you don't need to store the raw images, and also because if you have a very large database of employees, you don't need to compute these encodings every single time for every employee in your database, this idea of pre computing some of these encodings can save significant money computation. And this type of precomputation works both for this type of Siamese network architecture, where you treat face recognition as a binary classification problem, as well as for when you were learning encodings, maybe using the triplet loss function as described in the last couple of videos. And so just to wrap up, to treat face verification as supervised learning, you create a training set of just pairs of images. Now, instead of triplets of pairs of images, where the target label is one, when these are a pair of pictures of the same person, and where the Target label is 0, when these are pictures of different persons and you use different pairs to train the neural network, to train the Siamese network using back propagation. So this version that you just saw of treating face verification and by extension face recognition as a binary classification problem, this works quite well as well. And so with that, I hope that you now know what it would take to train your own face verification or your own face recognition system, one that can do one shot learning.










