相关文章推荐
强悍的红烧肉  ·  java - Cannot mock ...·  1 年前    · 
发财的楼房  ·  vite --template vue & ...·  1 年前    · 
阳刚的小马驹  ·  javascript - ...·  1 年前    · 

本博客所有知识来源于百度paddle框架中的相关材料,只做分享,大家可以在github搜索paddle框架的相关内容。

1. 简介

在机器学习中,我们经常会遇到度量数据间距离的问题。一般来说,对于可度量的数据,我们可以直接通过欧式距离(Euclidean Distance),向量内积(Inner Product)或者是余弦相似度(Cosine Similarity)来进行计算。但对于非结构化数据来说,我们却很难进行这样的操作,如计算一段视频和一首音乐的匹配程度。由于数据格式的不同,我们难以直接进行上述的向量运算,但先验知识告诉我们 ED(laugh_video, laugh_music) < ED(laugh_video, blue_music), 如何去有效得表征这种”距离”关系呢? 这就是 Metric Learning 所要研究的课题。

Metric learning 全称是 Distance Metric Learning,它是通过机器学习的形式,根据训练数据,自动构造出一种基于特定任务的度量函数。Metric Learning 的目标是学习一个变换函数(线性非线性均可)L,将数据点从原始的向量空间映射到一个新的向量空间,在新的向量空间里相似点的距离更近,非相似点的距离更远,使得度量更符合任务的要求,如下图所示。 Deep Metric Learning,就是用深度神经网络来拟合这个变换函数。

2. 应用

Metric Learning 技术在生活实际中应用广泛,如我们耳熟能详的人脸识别(Face Recognition)、行人重识别(Person ReID)、图像检索(Image Retrieval)、细粒度分类(Fine-grained classification)等。随着深度学习在工业实践中越来越广泛的应用,目前大家研究的方向基本都偏向于 Deep Metric Learning(DML).

一般来说, DML 包含三个部分: 特征提取网络来 map embedding, 一个采样策略来将一个 mini-batch 里的样本组合成很多个 sub-set, 最后 loss function 在每个 sub-set 上计算 loss. 如下图所示:

3. 算法

Metric Learning 主要有如下两种学习范式:

3.1 Classification based:

这是一类基于分类标签的 Metric Learning 方法。这类方法通过将每个样本分类到正确的类别中,来学习有效的特征表示,学习过程中需要每个样本的显式标签参与 Loss 计算。常见的算法有 L2-Softmax , Large-margin Softmax , Angular Softmax , NormFace , AM-Softmax , CosFace , [ArcFace]( https://arxiv.org/abs/1801.07698)等。 这类方法也被称作是 proxy-based, 因为其本质上优化的是样本和一堆 proxies 之间的相似度。

3.2 Pairwise based:

这是一类基于样本对的学习范式。他以样本对作为输入,通过直接学习样本对之间的相似度来得到有效的特征表示,常见的算法包括: Contrastive loss , Triplet loss , Lifted-Structure loss , N-pair loss , [Multi-Similarity loss]( https://arxiv.org/pdf/1904.06627.pdf)等

2020 年发表的[CircleLoss]( https://arxiv.org/abs/2002.10857),从一个全新的视角统一了两种学习范式,让研究人员和从业者对 Metric Learning 问题有了更进一步的思考。

度量学习 Metric L ear ning ) 度量( Metric )的定义  在数学中,一个度量(或距离函数)是一个定义集合中元素之间距离的函数。一个具有度量的集合被称为度量空间。 1 为什么要用 度量学习 ? 很多的算法越来越依赖于在输入空间给定的好的度量。例如K-means、K近邻方法、SVM等算法需要给定好的度量来反映数据间存在的一些重要关系。这一问题在无监督的方法(如聚类)中尤为明显。举一
2018年04月10日 15:30:29 敲代码的quant 阅读数:1567 标签: 度量学习 metric l ear ning 机器 学习 聚类 更多 个人分类: 机器 学习 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/FrankieHello/article/details/79872607 看到一篇知乎大神Flood Sung发表在CV...
度量学习 ( Metric L ear ning ) == 距离 度量学习 (Distance Metric L ear ning ,DML) == 相似度 学习 度量学习 是指 距离 度量学习 ,Distance Metric L ear ning ,简称为 DML,是人脸识别中常用传统机器 学习 方法,由Eric Xing在NIPS 2002提出。 度量学习 Metric L ear ning )也就是常说的相似度 学习 。如果...
The metric l ear ning problem is concerned with l ear ning a distance function tuned to a particular task, and has been shown to be useful when used in conjunction with n ear est-neighbor methods and other techniques that rely on distances or similarities. This survey presents an overview of existing res ear ch in metric l ear ning , including recent progress on scaling to high-dimensional feature spaces and to data sets with an extremely large number of data points. A goal of the survey is to present as unified as possible a framework under which existing res ear ch on metric l ear ning can be cast. The first part of the survey focuses on lin ear metric l ear ning approaches, mainly concentrating on the class of Mahalanobis distance l ear ning methods. We then discuss nonlin ear metric l ear ning approaches, focusing on the connections between the nonlin ear and lin ear approaches. Finally, we discuss extensions of metric l ear ning , as well as applications to a variety of problems in computer vision, text analysis, program analysis, and multimedia.
度量学习 之参考指南 度量学习 是指距离 度量学习 ,Distance Metric L ear ning ,简称为 DML,广泛 应用 计算机视觉 中的图像检索和分类、人脸识别、人类活动识别和姿势估计,文本分析和一些其他领域如音乐分析,自动化的项目调试,微阵列数据分析等, 度量学习 是Eric P. Xing, Andrew Y. Ng等人在NIPS 2003提出。 这并不是个新词,说的直...
度量学习 应用 基本可以涵盖各种领域,最近需要当作工具使用,用的语言是 python ,网上直接有工具包 metric -l ear n,可以直接使用pip install metric -l ear n的方法来安装,或者根据前面github上的网址下载源码之后 python setup.py install. 安装好之后就可以使用包中带的一些 度量学习 的方法了,以下的例子均摘自此处 Covariance met...
首先,我们把loss归为两类:一类是本篇讲述的基于softmax的,一类是基于pair对的(如对比损失、三元损失等)。 基于pair对的,参考我的另一篇博客:https://blog.csdn.net/u012863603/article/details/119246720 基于softmax的改进主要有如下(有的loss拥有不同的名字):softmax、center loss、range loss、Modified softmax、NormFace、large m... 请参阅 以获取可以在Google Colab上下载或运行的 笔记 本的 。 PyTorch 公制 学习 概述 该库包含9个模块,每个模块都可以在您现有的代码库中独立使用,或组合在一起以形成完整的培训/测试工作流程。 损失函数如何工作 在训练循环中使用损失和矿工 让我们初始化一个简单的 : from pytorch _ metric _l ear ning import losses loss_func = losses . TripletMarginLoss () 要在训练循环中计算损失,请传递模型计算的嵌入以及相应的标签。 嵌入的大小应为(N,embedding_size),标签的大小应为(N),其中N为批处理大小。 # your trai ning loop for i , ( data , labels ) in enumerate ( dataloader ): optimiz
Metric l ear ning is a type of machine l ear ning technique that involves l ear ning a metric , or a distance function, between pairs of data points in a dataset. The goal of metric l ear ning is to l ear n a metric that can accurately capture the similarity or dissimilarity between pairs of data points, such that similar points are closer together in the l ear ned metric space than dissimilar ones. Metric l ear ning has various applications in fields such as computer vision, natural language processing, and recommender systems. For example, in computer vision, metric l ear ning can be used to l ear n a metric that can accurately measure the similarity between images, which can be used for tasks such as image retrieval or object recognition. In natural language processing, metric l ear ning can be used to l ear n a metric that can measure the similarity between sentences or documents, which can be used for tasks such as text classification or information retrieval. Some popular techniques for metric l ear ning include siamese networks, triplet networks, and contrastive l ear ning . These techniques involve l ear ning a mapping function that maps input data points to a low-dimensional metric space, such that the distance between pairs of points in this space accurately reflects their similarity or dissimilarity.
x = self.layer1(x) # 128x128x64 -> 128x128x256 x = self.seattention128(x) x = self.layer2(x) # 128x128x256 -> 64x64x512 #添加了一个注意力机制 x= self.seattention64(x) x = self.layer3(x) # 64x64x512 -> 32x32x1024 x=self.seattention32(x) x = self.layer4(x) x = self.avgpool(x) x = x.view(x.size(0), -1) x = self.fc(x) return x 是把这里的self.conv1替换吗 知识蒸馏算法和代码(Pytorch)笔记分享,一个必须要了解的算法 康康好老啊: 报错信息的意思是输入必须是一个张量而不是元组,你可以尝试打印一下输入的类型,元组和张量之间是可以互相转换的