C4W4L03 Siamese Network

DeepLearningAI · Beginner ·📐 ML Fundamentals ·8y ago

Key Takeaways

The video discusses the Siamese Network architecture for face recognition, where two identical convolutional neural networks are used to compare two input images and determine their similarity. The network is trained using a triplet loss function to learn an encoding that minimizes the distance between images of the same person and maximizes the distance between images of different people.

Full Transcript

the job of the function D which you learned about in the last video is to input two faces and tell you how similar or how different they are a good way to do this is to use a Siamese Network let's take a look you're used to seeing pictures of confidence like these where you input an image let's say X 1 and through a sequence of convolutional and pulling and fully connected layers and with a feature vector like that and sometimes this is fed to a softmax unit to make a classification but we're gonna not going to use that in this video instead we're going to focus on this vector of let's say 128 numbers computed by some fully connected layer that is deeper in the network and I'm going to give this this of 128 numbers a name I'm going to call this f of X 1 and you should think of f of X 1 as an encoding of the input image X 1 so it's taken the input image here this picture of kion and is re representing it as a vector of 128 numbers the way you can build a face-recognition system is then that if you want to compare two pictures let's say this first picture with this second picture here what you can do is feed the second picture to the same neural network with the same parameters and get a different vector of 128 numbers which represents or which encodes the second picture so I'm going to call this second picture so I'm going to call this encoding of this second picture f of X 2 and here I'm using X 1 and X 2 just to denote two input images they don't necessarily have to be the first and second examples in your training sets it can be any two pictures finally if you believe that these encoding x' are a good representation of these two images what you can do is then to find the image of distance between X 1 and X 2 has the norm of the difference between the encoding of these two images so this idea of running two identical convolutional neural networks on two different inputs and then comparing them sometimes that's called a Siamese neural network architecture and a lot of the ideas I'm presenting here came from this paper due to yawn of Tackman Minyoung marker really Renato and Leo wolf in a research system that they developed called deep face and many of the ideas I'm presenting here came from a paper due to yawn of Todman Minyoung marker really Renato and Leo wolf in the system that they developed called deep face so how do you train this siamese neural network remember that these two neural networks have the same parameters so what you want to do is really train a neural network so that the encoding that it computes results in a function D that tells you when two pictures are of the same person so more formally the parameters of the neural network define an encoding f of X I so given any input image X I the neural network oprah's this engine 28 dimensional encoding f of X I so more formally what you want to do is learn parameters so that if two pictures X I and XJ are of the same person then you want that distance between their encodings to be small and in the previous slide I was using x1 and x2 but is really any pair X I and XJ from your training set and in contrast if X I XJ are of different persons then you want that distance between their encodings to be large so as you vary the parameters and all of these layers of the neural net where you end up with different and coatings and what you can do is use back propagation to vary all those parameters in order to make sure these conditions are satisfied so you've learned about the siamese network architecture and have a sense of what you want the neural network to output for you in terms of what would make a good encoding but how do you actually define an objective function to make your new network learn to do what we just discussed here let's see how you can do that to the next video using the triplet loss function

Original Description

Take the Deep Learning Specialization: http://bit.ly/32Rqs4S Check out all our courses: https://www.deeplearning.ai Subscribe to The Batch, our weekly newsletter: https://www.deeplearning.ai/thebatch Follow us: Twitter: https://twitter.com/deeplearningai_ Facebook: https://www.facebook.com/deeplearningHQ/ Linkedin: https://www.linkedin.com/company/deeplearningai
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from DeepLearningAI · DeepLearningAI · 0 of 60

← Previous Next →
1 Forward and Backward Propagation (C1W4L06)
Forward and Backward Propagation (C1W4L06)
DeepLearningAI
2 deeplearning.ai's Heroes of Deep Learning: Yuanqing Lin
deeplearning.ai's Heroes of Deep Learning: Yuanqing Lin
DeepLearningAI
3 deeplearning.ai's Heroes of Deep Learning: Ruslan Salakhutdinov
deeplearning.ai's Heroes of Deep Learning: Ruslan Salakhutdinov
DeepLearningAI
4 deeplearning.ai's Heroes of Deep Learning: Yoshua Bengio
deeplearning.ai's Heroes of Deep Learning: Yoshua Bengio
DeepLearningAI
5 deeplearning.ai's Heroes of Deep Learning: Pieter Abbeel
deeplearning.ai's Heroes of Deep Learning: Pieter Abbeel
DeepLearningAI
6 deeplearning.ai's Heroes of Deep Learning: Ian Goodfellow
deeplearning.ai's Heroes of Deep Learning: Ian Goodfellow
DeepLearningAI
7 deeplearning.ai's Heroes of Deep Learning: Andrej Karpathy
deeplearning.ai's Heroes of Deep Learning: Andrej Karpathy
DeepLearningAI
8 Using an Appropriate Scale (C2W3L02)
Using an Appropriate Scale (C2W3L02)
DeepLearningAI
9 Gradient Checking (C2W1L13)
Gradient Checking (C2W1L13)
DeepLearningAI
10 Gradient Checking Implementation Notes (C2W1L14)
Gradient Checking Implementation Notes (C2W1L14)
DeepLearningAI
11 Learning Rate Decay (C2W2L09)
Learning Rate Decay (C2W2L09)
DeepLearningAI
12 Understanding Mini-Batch Gradient Dexcent (C2W2L02)
Understanding Mini-Batch Gradient Dexcent (C2W2L02)
DeepLearningAI
13 Mini Batch Gradient Descent (C2W2L01)
Mini Batch Gradient Descent (C2W2L01)
DeepLearningAI
14 The Problem of Local Optima (C2W3L10)
The Problem of Local Optima (C2W3L10)
DeepLearningAI
15 Exponentially Weighted Averages (C2W2L03)
Exponentially Weighted Averages (C2W2L03)
DeepLearningAI
16 Tuning Process (C2W3L01)
Tuning Process (C2W3L01)
DeepLearningAI
17 Understanding Exponentially Weighted Averages (C2W2L04)
Understanding Exponentially Weighted Averages (C2W2L04)
DeepLearningAI
18 Bias Correction of Exponentially Weighted Averages (C2W2L05)
Bias Correction of Exponentially Weighted Averages (C2W2L05)
DeepLearningAI
19 Gradient Descent With Momentum (C2W2L06)
Gradient Descent With Momentum (C2W2L06)
DeepLearningAI
20 Normalizing Activations in a Network (C2W3L04)
Normalizing Activations in a Network (C2W3L04)
DeepLearningAI
21 Hyperparameter Tuning in Practice (C2W3L03)
Hyperparameter Tuning in Practice (C2W3L03)
DeepLearningAI
22 Adam Optimization Algorithm (C2W2L08)
Adam Optimization Algorithm (C2W2L08)
DeepLearningAI
23 RMSProp (C2W2L07)
RMSProp (C2W2L07)
DeepLearningAI
24 Fitting Batch Norm Into Neural Networks (C2W3L05)
Fitting Batch Norm Into Neural Networks (C2W3L05)
DeepLearningAI
25 Why Does Batch Norm Work? (C2W3L06)
Why Does Batch Norm Work? (C2W3L06)
DeepLearningAI
26 Batch Norm At Test Time (C2W3L07)
Batch Norm At Test Time (C2W3L07)
DeepLearningAI
27 Softmax Regression (C2W3L08)
Softmax Regression (C2W3L08)
DeepLearningAI
28 Deep Learning Frameworks (C2W3L10)
Deep Learning Frameworks (C2W3L10)
DeepLearningAI
29 Neural Network Overview (C1W3L01)
Neural Network Overview (C1W3L01)
DeepLearningAI
30 Training Softmax Classifier (C2W3L09)
Training Softmax Classifier (C2W3L09)
DeepLearningAI
31 Why Deep Representations? (C1W4L04)
Why Deep Representations? (C1W4L04)
DeepLearningAI
32 Gradient Descent For Neural Networks (C1W3L09)
Gradient Descent For Neural Networks (C1W3L09)
DeepLearningAI
33 Neural Network Representations (C1W3L02)
Neural Network Representations (C1W3L02)
DeepLearningAI
34 TensorFlow (C2W3L11)
TensorFlow (C2W3L11)
DeepLearningAI
35 Activation Functions (C1W3L06)
Activation Functions (C1W3L06)
DeepLearningAI
36 Explanation For Vectorized Implementation (C1W3L05)
Explanation For Vectorized Implementation (C1W3L05)
DeepLearningAI
37 Getting Matrix Dimensions Right (C1W4L03)
Getting Matrix Dimensions Right (C1W4L03)
DeepLearningAI
38 Understanding Dropout (C2W1L07)
Understanding Dropout (C2W1L07)
DeepLearningAI
39 Building Blocks of a Deep Neural Network (C1W4L05)
Building Blocks of a Deep Neural Network (C1W4L05)
DeepLearningAI
40 Why Non-linear Activation Functions (C1W3L07)
Why Non-linear Activation Functions (C1W3L07)
DeepLearningAI
41 Computing Neural Network Output (C1W3L03)
Computing Neural Network Output (C1W3L03)
DeepLearningAI
42 Backpropagation Intuition (C1W3L10)
Backpropagation Intuition (C1W3L10)
DeepLearningAI
43 Train/Dev/Test Sets (C2W1L01)
Train/Dev/Test Sets (C2W1L01)
DeepLearningAI
44 Deep L-Layer Neural Network (C1W4L01)
Deep L-Layer Neural Network (C1W4L01)
DeepLearningAI
45 Random Initialization (C1W3L11)
Random Initialization (C1W3L11)
DeepLearningAI
46 Other Regularization Methods (C2W1L08)
Other Regularization Methods (C2W1L08)
DeepLearningAI
47 Normalizing Inputs (C2W1L09)
Normalizing Inputs (C2W1L09)
DeepLearningAI
48 Derivatives Of Activation Functions (C1W3L08)
Derivatives Of Activation Functions (C1W3L08)
DeepLearningAI
49 Parameters vs Hyperparameters (C1W4L07)
Parameters vs Hyperparameters (C1W4L07)
DeepLearningAI
50 Vectorizing Across Multiple Examples (C1W3L04)
Vectorizing Across Multiple Examples (C1W3L04)
DeepLearningAI
51 What does this have to do with the brain? (C1W4L08)
What does this have to do with the brain? (C1W4L08)
DeepLearningAI
52 Dropout Regularization (C2W1L06)
Dropout Regularization (C2W1L06)
DeepLearningAI
53 Vanishing/Exploding Gradients (C2W1L10)
Vanishing/Exploding Gradients (C2W1L10)
DeepLearningAI
54 Basic Recipe for Machine Learning (C2W1L03)
Basic Recipe for Machine Learning (C2W1L03)
DeepLearningAI
55 Bias/Variance (C2W1L02)
Bias/Variance (C2W1L02)
DeepLearningAI
56 Forward Propagation in a Deep Network (C1W4L02)
Forward Propagation in a Deep Network (C1W4L02)
DeepLearningAI
57 Weight Initialization in a Deep Network (C2W1L11)
Weight Initialization in a Deep Network (C2W1L11)
DeepLearningAI
58 Numerical Approximations of Gradients (C2W1L12)
Numerical Approximations of Gradients (C2W1L12)
DeepLearningAI
59 Regularization (C2W1L04)
Regularization (C2W1L04)
DeepLearningAI
60 Why Regularization Reduces Overfitting (C2W1L05)
Why Regularization Reduces Overfitting (C2W1L05)
DeepLearningAI

The Siamese Network architecture is used for face recognition by comparing two input images and determining their similarity. The network is trained using a triplet loss function to learn an encoding that minimizes the distance between images of the same person and maximizes the distance between images of different people.

Key Takeaways
  1. Define the Siamese Network architecture
  2. Implement the triplet loss function
  3. Train the neural network using a dataset of images
  4. Evaluate the network's performance using a test dataset
💡 The Siamese Network architecture can be used for face recognition by learning an encoding that minimizes the distance between images of the same person and maximizes the distance between images of different people.

Related Reads

📰
Day 156 of Learning Java & DSA: Checking Balanced Parentheses Using Stack
Learn to implement a stack to check balanced parentheses in Java, a crucial skill for any programmer
Medium · Programming
📰
Beyond Tutorials: How to Start Machine Learning the Right Way (A Practical Roadmap That Actually…
Learn to start machine learning the right way by focusing on teaching computers to learn patterns and developing your own thinking skills
Medium · Machine Learning
📰
Beyond Tutorials: How to Start Machine Learning the Right Way (A Practical Roadmap That Actually…
Learn to start machine learning the right way by focusing on teaching computers to learn patterns and developing your own thinking skills
Medium · Programming
📰
A Python/C++ Pipeline for Embarrassingly Parallel Simulations
Learn to build a parallel simulation pipeline using Python and C++ for efficient computation
Dev.to · Hiroshi Watanabe
Up next
More Trees Won't Fix Your Random Forest
DataMListic
Watch →