face recognition&&one-shot learning

本文介绍人脸验证与识别的基本概念,包括1对1验证问题、人脸识别系统中的oneshot learning挑战、用于衡量图片差异的Similarity函数、Siamese网络结构、Triplet损失函数的应用以及如何通过二分类改进Simaese网络等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、人脸验证与人脸识别:

(1)人脸验证(Verification)

Input:图片、名字/ID

Output:输入的图片是否是对应的人

1 to 1问题

(2)人脸识别(recognition)

拥有一个具有K个人的数据库

输入一副人脸图像

如果图片是任意这k个人中的一位,则输出对应人的ID

2、one shot learning

对于大多数的人脸识别系统都存在一个问题就是one shot learning

对于一个人脸识别系统来说,我们需要仅仅通过先前的一张人脸的图片或者是一个样例,就实现对人的识别,这样的问题就是one shot learning,系统可以识别到对应的人。

对于one shot learning来说,因为只有单个样本,是不足以训练一个稳健的卷积神经网络来进行不同人的识别过程。而且如果有新的成员加入的话,还需要对网络重新训练,这是不现实的。

3、Similarity函数:

(1)d(img1, img2):两幅图片的差异

(2)Input:two images

(3)Output:差异度

(3)if d(img1, img2) <= threshold

Similarity函数实现:

d(x1, x2) = ||f(x1)-f(x2)))||_2^2

因此:如果x1,x2是同一幅图片,那么d(x1, x2)很小,反之很大

 

 

4、Siamese网络:

对于一个卷积网络,我们去掉最后的softmax层,将图片输入,最后输出一个N维的向量(图中以N=128)。将不同人的图片样本输入相同参数的网络结构,得到各自的图片的编码。

5、Triplet损失函数

为了使用Triplet损失函数,我们需要比较成对的图像(三元组术语)

(1)Anchor(A):目标图片

(2)Positive(P):与A同一人的图片

(3)Negative(N):与A不同人的图片

所以:d(A, P)=||f(A)-f(P)||^2\leqslant ||f(A)-f(N)||^2=d(A, N)

也就是||f(A)-f(P)||^2-||f(A)-f(N)||^2\leqslant0

上面的公式存在一个问题,就是当f(A)=f(P)=f(N)=0时,也就是神经网络学习到的函数总是输出0时,或者f(A)=f(P)=f(N)时,也满足上面的公式,为了防止出现这些情况,我们对上式进行修改:

||f(A)-f(P)||^2-||f(A)-f(N)||\leqslant -\alpha(称为"margin")即:

||f(A)-f(P)||^2-||f(A)-f(N)||^2+\alpha\leqslant 0\alpha作为超参数,不同大小有不同的效果。

因此通过上面的推到我们可以定义triplet损失函数

L(A,P,N)=max(z, 0)=max(||f(A)-f(P)||^2-||f(A)-f(N)||^2+\alpha, 0)

理解:当z小于0时,我们可以认为这个差距是满足我们的要求的,不需要对参数调整做出贡献,因此,我们可以把代价作为0,即0与负数中的较大值0,当z大于0时,相同图片的编码差异比不同图片的编码差异还大,这是需要做出调整的,因此计入损失函数中。

整个网络的代价:

J=\sum_{i=1}^mL(A^{(i)},P^{(i)},N^{(i)})

6、Simaese二分类改进

除了利用上面的Triplet损失函数来学习人脸识别卷积网络参数的方法外,还有其他方式。我们可以将人脸识别问题利用Siamese网络当成一个二分类问题,同样可以实现参数的学习。

对两张图片应用Simaese网络,计算得到两张图片的N维编码,然后将两个编码输入到一个logistic regression单元中,然后进行预测。相同的人则输出1,否则输出0。

对于最后的sigmoid函数,我们可以进行如下计算:

A = \sigma (\sum_{k=1}^Nw_i|f(x^{(i)})_k-f(x^{(j)})_k|+b )

将两个向量对应元素的差值作为特征输入到logistic regression的单元中,增加参数w_ib,通过训练得到合适的参数权重和偏置,进而判断两张图片是否是同一个人。同时输入逻辑回归单元还可以进行更改:

\frac{(f(x^{(i)})_k-f(x^{(j)})_k)^2}{f(x^{(i)})_k+f(x^{(j)})_k},也称为卡方公式、卡方相似度。

在实际的人脸验证系统中,我们可以对数据库的人脸图片进行预计算,存储卷积网络得到的编码。当有图片进行识别时,运用卷积网络计算新图片的编码,与预计算保存好的编码输入到逻辑回归单元中进行预测。这样可以提高我们系统预测的效率,节省计算时间。

利用Siamese 网络,我们可以将人脸验证当作一个监督学习,创建成对的训练集和是否同一个人的输出标签。

以上内容来自:https://zhuanlan.zhihu.com/p/31485345

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

### Few-Shot Learning Introduction Few-shot learning refers to a class of machine learning problems where the model is required to learn from very few examples, typically one or just a handful per category. This approach mimics human ability to generalize from limited data and has become an important area within deep learning research. The task layer's prior knowledge includes all methods that "learn how to learn," such as optimizing parameters for unseen tasks through meta-learning techniques which can provide good initialization for novel tasks[^1]. In this context: - **Meta-Learning**: Aims at designing models capable of fast adaptation with minimal training samples by leveraging previously acquired experience. - **Metric Learning**: Focuses on learning distance metrics between instances so similar ones are closer together while dissimilar remain apart in embedding space. #### Applications in Machine Learning One prominent application involves fine-grained classification using small datasets like Mini-ImageNet, demonstrating performance improvements when comparing different algorithms' embeddings propagation capabilities over time steps (Figure 7)[^2]. Another example comes from multi-label classification scenarios where combining MLP classifiers alongside KNN-based predictions enhances overall accuracy compared to traditional approaches relying solely upon prototype definitions derived directly from support sets during inference phases[^3]. Moreover, hybrid embedding strategies have been explored; these integrate both generalizable features learned across diverse domains along with specialized adjustments made specifically towards target-specific characteristics present only within given training distributions[Dtrain], thereby improving adaptability without sacrificing efficiency too much relative purely invariant alternatives[^4]. ```python def few_shot_classifier(embedding_model, classifier_type='mlp_knn'): """ Demonstrates a simple implementation outline for integrating Multi-layer Perceptron (MLP) and k-nearest neighbors (KNN). Args: embedding_model: Pre-trained neural network used to generate feature vectors. classifier_type: Type of final decision mechanism ('mlp', 'knn', or 'mlp_knn'). Returns: Combined prediction scores based on selected strategy. """ pass # Placeholder function body ``` --related questions-- 1. What specific challenges do few-shot learning systems face? 2. How does metric learning contribute to enhancing few-shot recognition abilities? 3. Can you explain more about the role of prototypes in few-shot classification schemes? 4. Are there any notable differences between MAML and other optimization-based meta-learning frameworks? 5. Which types of real-world problems benefit most significantly from applying few-shot learning methodologies?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值