Imagine you have a photo of a face. A face embedding is a way to turn that photo into a list of numbers. What do these numbers represent?
Think about how a fingerprint summarizes unique patterns.
Face embeddings are numeric vectors that capture unique facial features, allowing easy comparison between faces.
Given two face embeddings as numpy arrays, what is the output of the cosine similarity calculation?
import numpy as np embedding1 = np.array([1, 0, 0]) embedding2 = np.array([0, 1, 0]) cos_sim = np.dot(embedding1, embedding2) / (np.linalg.norm(embedding1) * np.linalg.norm(embedding2)) print(round(cos_sim, 2))
Cosine similarity measures angle between vectors; orthogonal vectors have similarity zero.
The two embeddings are orthogonal (at 90 degrees), so cosine similarity is 0.
Which type of neural network model is best suited to generate face embeddings that capture facial features effectively?
Think about models good at processing images.
CNNs are designed to extract spatial features from images, making them ideal for face embeddings.
You have two face embeddings and want to decide if they belong to the same person. Which metric is most commonly used for this comparison?
Think about measuring angle similarity between vectors.
Cosine similarity measures how close two vectors point in the same direction, useful for face embeddings.
Consider this code snippet to compare two face embeddings:
embedding1 = [0.1, 0.2, 0.3] embedding2 = [0.1, 0.2, 0.3] cos_sim = sum(embedding1 * embedding2) / (sum(embedding1**2)**0.5 * sum(embedding2**2)**0.5) print(round(cos_sim, 2))
What error will this code raise?
Look at how lists are multiplied in Python.
Lists cannot be multiplied element-wise with * operator; this causes a TypeError.