Abstract
    In this work, we develop methods for few-shot image classification from a new perspective of optimal matching between image regions. We employ the Earth Mover’s Distance (EMD) as a metric to compute a structural distance between dense image representations to determine image relevance. The EMD generates the optimal matching flows between structural elements that have the minimum matching cost, which is used to calculate the image distance for classification. To generate the important weights of elements in the EMD formulation, we design a cross-reference mechanism, which can effectively alleviate the adverse impact caused by the cluttered background and large intra-class appearance variations. To implement $k$-shot classification, we propose to learn a structured fully connected layer that can directly classify dense image representations with the EMD. Based on the implicit function theorem, the EMD can be inserted as a layer into the network for end-to-end training. Our extensive experiments validate the effectiveness of our algorithm which outperforms state-of-the-art methods by a significant margin on five widely used few-shot classification benchmarks, namely, miniImageNet, tieredImageNet, Fewshot-CIFAR100 (FC100), Caltech-UCSD Birds-200-2011 (CUB), and CIFAR-FewShot (CIFAR-FS). We also demonstrate the effectiveness of our method on the image retrieval task in our experiments.

    在本工作中,我们从图像区域间最优匹配的新角度开发了一种少镜头图像分类方法。我们使用地球移动距离(EMD)作为度量来计算密集图像表示之间的结构距离,以确定图像相关性。EMD生成匹配代价最小的结构元素之间的最优匹配流,用于计算图像距离进行分类。为了生成EMD公式中元素的重要权值,我们设计了一种交叉引用机制,可以有效地缓解背景杂乱和类内外观变化大所带来的不利影响。为了实现$k$-shot分类,我们提出学习一个结构化的全连接层,该层可以直接使用EMD对密集图像表示进行分类。基于隐函数定理,可以将EMD作为一层插入到网络中进行端到端的训练。我们广泛的实验验证了我们的算法的有效性,在5个广泛使用的少镜头分类基准上,即miniImageNet、tieredImageNet、Fewshot-CIFAR100 (FC100)、Caltech-UCSD bird200 -2011 (CUB)和CIFAR-FewShot (CIFAR-FS),其性能显著优于最先进的方法。在实验中,我们也证明了该方法在图像检索任务中的有效性。

    \IEEEraisesectionheading{\section{Introduction}\label{sec:introduction}}

    Deep neural networks have achieved great success in many vision tasks, typically requiring a large amount of labeled data. A notorious drawback of deep learning methods is that they suffer from poor sample efficiency. This is in sharp contrast to how we humans learn. In machine learning, few-shot learning is the task that addresses this issue, which is often solved as a special case of the broader meta learning. Meta learning attempts to learn a model that can generalize to new tasks with minimum adaption effort. One of the most well-studied test-beds for meta-learning algorithms is few-shot image classification, which aims to perform classification on new image categories with only a limited amount of labeled training data. This is the focus of our work here.
    深度神经网络在许多视觉任务中取得了巨大的成功,这些任务通常需要大量的标记数据。深度学习方法的一个臭名昭著的缺点是样本效率低。这与我们人类的学习方式形成了鲜明的对比(人类利用进化已经形成了有效的归纳偏置)。在机器学习中,少镜头学习就是解决这个问题的任务,它通常作为更广泛的元学习的一个特殊情况来解决。元学习试图学习一个模型,以最小的适应努力可以推广到新的任务。少镜头图像分类是元学习算法中研究最充分的一个测试平台,它旨在用有限数量的标注训练数据对新的图像类别进行分类(我还是喜欢datasetGAN的方案)。这是我们这里工作的重点。

    To tackle this problem, a line of previous work in literature adopts metric-based methods~\cite{matchnet,proto,feat,TADAM,relation,Revisiting} that learn to represent image data in an appropriate feature space and use a distance function to predict image labels. Following the formulation of the standard image classification networks~\cite{cnn,resnet}, metric-based methods often employ a convolution neural network to learn image feature representations and replace the fully connected layer with a distance function, \eg, the \emph{cosine} distance and Euclidean distance. Such distance functions directly compute the distances between the embeddings of the test images and training images for classification, which bypasses the difficult optimization problem in learning a classifier in the few-shot setting. The network is usually trained by sampling from a distribution of tasks, in the hope of acquiring a good generalization ability to unseen but similar tasks.
    为了解决这一问题,文献中有一种基于度量的方法~\cite{matchnet,proto,feat,TADAM,relation, revisit}学习在适当的特征空间中表示图像数据,并使用距离函数预测图像标签。在标准图像分类网络的制定过程中,基于度量的方法通常使用卷积神经网络来学习图像特征表示,并将全连接层替换为一个距离函数,例如,emph{cos}距离和欧几里德距离。这种距离函数直接计算用于分类的测试图像的嵌入与训练图像之间的距离,从而避开了在少镜头的情况下学习分类器时的困难优化问题。通常通过对任务分布进行抽样来训练网络,以期对不可见但相似的任务获得良好的泛化能力。

    Although these methods have achieved some degree of success, we observe that the cluttered background and large intra-class appearance variations may drive the image-level embeddings from the same category far apart in a given metric space. This issue can be largely alleviated by deep neural networks under the setting of fully supervised learning, thanks to the large capacity of deep models and sufficient training images. However, it is almost inevitably amplified in low-data regimes and thus adversely impacts the image classification accuracy. Moreover, a mixed global representation would struggle to well capture image structures and is likely to lose useful local feature characteristics. Local features can provide discriminative and transferable information across categories, which can be important cues for image classification in the few-shot scenario. Therefore, a desirable metric-based algorithm should have the ability to exploit the local discriminative information and minimize the distraction caused by irrelevant regions.
    虽然这些方法取得了一定程度的成功,但我们观察到,杂乱的背景和较大的类内外观变化可能会导致同一类在给定度量空间中距离较远的图像级嵌入。深度神经网络在全监督学习的设置下,由于深度模型容量大,训练图像充足,大大缓解了这一问题。然而,在低数据状态下,它几乎不可避免地会被放大,从而对图像分类精度产生不利影响。此外,混合全局表示将难以很好地捕捉图像结构,并可能失去有用的局部特征特征。局部特征可以提供具有鉴别性和可转移性的跨类别信息,在镜头较少的场景下,局部特征可以作为图像分类的重要线索。因此,一个理想的基于度量的算法应该能够利用局部的鉴别信息,并将无关区域引起的干扰最小化。

    A natural approach to determine the similarity of two complex structured representations is to compare their building blocks. The difficulty lies in that we do not have their correspondence supervision for training and not all building elements can always find their counterparts in the other structures. To solve the problems above, in this paper, we formalize the few-shot classification as an instance of optimal matching, and we propose to use the optimal matching cost between two structures to represent their dissimilarity. Given the local feature representation sets generated by two images, we use the Earth Mover’s Distance (EMD)~\cite{emd} to compute their structural similarity. The EMD is a metric for computing distance between structured representations, which was originally proposed for image retrieval. Given the distance between all element pairs, the EMD can acquire the optimal matching flows between two structures that have the minimum overall distance. It can also be interpreted as the minimum cost to reconstruct a structured representation against the other one. An illustration of our motivation is shown in Fig.~\ref{fig:introduction}.
    确定两个复杂结构化表示的相似性的一种自然方法是比较它们的构建块。困难在于,我们没有相应的培训监督,并不是所有的建筑元素都能在其他结构中找到对应的元素。为了解决上述问题,本文将少镜头分类形式化为最优匹配的实例,并提出用两个结构之间的最优匹配代价来表示它们的不同之处。对于由两幅图像生成的局部特征表示集,我们使用地球移动距离(EMD)来计算它们的结构相似度。EMD是一种计算结构表示之间距离的度量,最初是为了进行图像检索而提出的。在给定所有单元对之间的距离的情况下,EMD可以得到两个结构之间总距离最小的最优匹配流。它也可以被解释为相对于另一种表示重构结构化表示的最小代价。图~\ref{图:引言}显示了我们的动机。
    image.png
    Illustration of using the Earth Mover’s Distance for one-shot image classification. Our method uses an optimal matching cost between image regions to represent the image distance more faithfully.
    使用地球移动者的距离进行一次图像分类的说明。我们的方法使用图像区域之间的最优匹配代价来更真实地表示图像距离。

    The EMD has the formulation of the transportation problem~\cite{transportation} and the global minimum can be attained by solving a Linear Programming problem. To embed the optimization problem into the model for end-to-end training, we apply the implicit function theorem~\cite{krantz2012implicit,dontchev2009implicit,barratt2018differentiability} to form the Jacobian matrix of the optimal optimization variables with respect to the problem parameters~\cite{barratt2018differentiability}. We explore multiple ways to extract local representations from an image, including fully convolutional networks, image grids, and image region sampling. We also investigate pyramid structures at both the feature level and the image level to capture local representations at different scales.
    EMD可以形式化为运输问题,其全局最小值可通过求解一个线性规划问题得到。端到端优化问题嵌入到模型训练,我们应用隐函数定理~ \引用{krantz2012implicit、dontchev2009implicit barratt2018differentiability}形成雅可比矩阵的最优参数优化变量的问题~ \引用{barratt2018differentiability}。我们探索了多种方法从图像中提取局部表示,包括全卷积网络、图像网格和图像区域采样。我们还在特征级和图像级研究金字塔结构,以捕获不同尺度上的局部表示。
    隐函数定理
    https://www.zhihu.com/question/29206025/answer/59760285
    https://zhuanlan.zhihu.com/p/410729940

    An important problem-specific parameter in the EMD formulation is the weight of each element. Elements with large weights generate more matching flows and thus contribute more to the overall distance. Ideally, the algorithm should accommodate the flexibility to assign less weight to irrelevant regions such that they contribute less to the overall distance no matter which elements they match with. To achieve this goal, we propose a cross-reference mechanism to determine the importance of the elements. In the proposed cross-reference mechanism, we determine the weight of each node by comparing it with the global statistics of the other structure. Intuitively, the image region that shows greater relevance to the other image is more likely to be the object region and should be assigned with a larger weight, while the weights of high-variance background regions and the object parts that are not co-occurrent in two images should be eliminated as much as possible when computing the matching cost.
    在EMD公式中,一个重要的具体问题参数是每个元素的权重。权重较大的元素生成更多匹配流,从而对整体距离的贡献更大。理想情况下,算法应该灵活地为不相关区域分配较少的权重,这样无论它们与哪个元素匹配,它们对总距离的贡献都较少。为了实现这一目标,我们建议建立一种相互参照机制,以确定各要素的重要性。在提出的交叉引用机制中,我们通过与其他结构的全局统计量比较来确定每个节点的权重。直观地说,显示出与其他图像更大相关性的图像区域更有可能是对象区域,应该分配一个更大的权重,而在计算匹配代价时,应尽量消除两幅图像中不同时出现的高方差背景区域和物体部分的权重。
    和二分图的匹配算法到底有什么关系

    In the $k$-shot setting where multiple support images are presented, we propose to learn a structured fully connected (FC) layer as the classifier for classification to make use of the increasing number of training images. The structured FC layer includes a group of learnable vectors for each class. At inference time, we use the EMD to compute the distance between the image embeddings and the learnable vector set in each class for classification. The structured FC is an extension of the standard fully connected layer in that it replaces dot product operations between vectors with the EMD function between vector sets such that the structured FC layer can directly classify feature maps. The structured FC layer can also be interpreted as learning the prototype embeddings generated by a dummy image for each category such that the test images can be matched with each of them for classification.
    在提供多个支持图像的$k$-shot设置中,我们建议学习一个结构化全连接(FC)层作为分类器,以利用不断增加的训练图像。结构化的FC层为每个类包含一组可学习的向量。在推理时,我们使用EMD计算图像嵌入到每个类的可学习向量集之间的距离来进行分类。结构化FC是标准全连通层的扩展,它用向量集之间的EMD函数代替向量之间的点积运算,从而使结构化FC层可以直接对特征映射进行分类。结构化的FC层也可以解释为学习由每个类别的虚拟图像生成的原型嵌入,这样测试图像就可以与每个类别匹配进行分类。

    To validate our algorithm, we conduct extensive experiments on multiple datasets to demonstrate the effectiveness of our algorithm. Our main contributions are summarized as follows:
    为了验证我们的算法,我们在多个数据集上进行了大量的实验来证明我们的算法的有效性。我们的主要贡献总结如下:

    \begin{itemize} % \itemsep -0.1cm

    \item We propose to formalize the few-shot image classification as an optimal matching problem and employ the Earth Mover’s Distance as the distance metric between structured representations. The EMD layer can be embedded into the network for end-to-end training.
    我们建议将少镜头图像分类形式化为一个最优匹配问题,并使用地球移动者的距离作为结构化表示之间的距离度量。EMD层可以嵌入到网络中进行端到端的训练。

    \item We propose a cross-reference mechanism to generate the weights of elements in the EMD formulation, which can effectively reduce the noise introduced by the irrelevant background regions in images.
    我们提出了一种生成EMD公式中元素权值的交叉引用机制,可以有效地降低图像中不相关背景区域引入的噪声。

    \item We propose to learn a structured fully connected layer in the $k$-shot settings, which is able to directly classify the structured representations of an image using the Earth Mover’s Distance.
    我们建议在$k$-shot设置中学习一个结构化的全连接层,它能够直接使用地球移动距离对图像的结构化表示进行分类。

    \item Experiments on five popular few-shot classification benchmark datasets—-miniImagenet, tieredImagenet, FC100, CUB, and CIFAR-FS show that our algorithm on both 1-shot and 5-shot classification tasks significantly outperforms the baseline methods and achieves new state-of-the-art performance. We also demonstrate that our method can effectively improve many deep metric learning methods on the image retrieval task.
    在miniImagenet, tieredImagenet, FC100, CUB和CIFAR-FS五个流行的少镜头分类基准数据集上进行的实验表明,我们的算法在1镜头和5镜头分类任务上都显著优于基线方法,取得了新的最先进的性能。我们还证明了我们的方法可以有效地改进图像检索任务中的许多深度度量学习方法。

    \end{itemize}

    Our preliminary result was published in~\cite{zhang2020deepemd}. To facilitate future research, the source code and trained models are made available at this link\footnote{ https://git.io/DeepEMD }.
    我们的初步结果发表在~\cite{zhang2020deepemd}。为了便于将来的研究,源代码和训练有素的模型可以在这个链接\脚注{https://git.io/DeepEMD}中找到。

    \section{Related Work}

    \textbf{Few-Shot Learning.} The research literature on few-shot learning shows great diversity \cite{Keshari18,FeiFeiFP06,GidarisCVPR2018,YanZH19,Wertheimer_2019_CVPR,wang2020instance,afrasiyabi2020associative,liu2020negative,lichtenstein2020tafssl,yu2020transmatch,xuattentional}. There are two main streams in the few-shot classification literature, metric-based approaches and optimization-based approaches. Optimization-based methods, \eg, \cite{MunkhdalaiICML18,SantoroBBWL16,closer,MunkhdalaiICML2017,ScottNIPS2018,PPA,Zhou2018deep,MetzICLR19,LeeICML18,LiICML2018,Luketina2016,Naik92,dense,Schonfeld_2019_CVPR,flennerhag2019meta,li2019learning,park2019meta,franceschi2018bilevel,rajeswaran2019meta,FranceschiICML18,qi2018low,simon2020adaptive,kim2020model,zhangiept,fei2021melr,oh2021boil,snell2020bayesian,patacchiola2020bayesian}, target at effectively adapting model parameters to new tasks in the low-shot regime. For example, MAML~\cite{maml} and many of its variants~\cite{trainmaml,leo,yaoyao,Jamal_2019_CVPR} aim to learn a good model initialization that can rapidly adapt to novel tasks with limited optimization steps. Our design is more related to the metric-based methods~\cite{matchnet,proto,feat,TADAM,relation,Revisiting,CAN,ctm,tieredimagenet,liu2019prototype,xing2019adaptive,Zhang_2021_CVPR}, which aim to represent samples in an appropriate feature space where data from different categories can be distinguished with distance metrics.
    关于少shot学习的研究文献显示出很大的多样性\引用{Keshari18,FeiFeiFP06,GidarisCVPR2018,YanZH19,Wertheimer_2019_CVPR,wang2020instance,afrasiyabi2020associative,liu2020negative,lichtenstein2020tafssl,yu2020transmatch,xuattentional}。在少镜头分类文献中有两大主流,基于度量的方法和基于优化的方法。文中针对方法\如\引用{MunkhdalaiICML18 SantoroBBWL16,近,MunkhdalaiICML2017 ScottNIPS2018, PPA, Zhou2018deep, MetzICLR19, LeeICML18, LiICML2018, Luketina2016, Naik92,密集,Schonfeld_2019_CVPR, flennerhag2019meta, li2019learning, park2019meta, franceschi2018bilevel, rajeswaran2019meta, FranceschiICML18, qi2018low, simon2020adaptive, kim2020model, zhangiept, fei2021melr, oh2021boiL,snell2020bayesian,patacchiola2020bayesian},目标是在低射状态下有效地调整模型参数以适应新的任务。例如,MAML~\cite{MAML}和它的许多变体~\cite{trainmaml,leo,yaoyao,Jamal_2019_CVPR}的目标是学习一个好的模型初始化,它可以快速适应新的任务,而只需要有限的优化步骤。我们的设计是基于指标的方法更多相关~ \引用{matchnet、原型、专长、TADAM关系,回顾,可以,中医,tieredimagenet, liu2019prototype, xing2019adaptive, Zhang_2021_CVPR},旨在在一个适当的代表样本特征空间数据与距离度量可以区分不同的类别。

    To achieve this goal, most previous methods represent the whole image as a data point in the feature space. There are also some works utilizing local features to make predictions. For example, Lifchitz~\etal~\cite{dense} directly make predictions with each local feature and fuse their results. Li \etal~\cite{Revisiting} adopt $k$-NN to fuse local distances. Cross Attention Networks~\cite{CAN} use attention mechanisms to highlight the target object regions and generate discriminative features for few-shot classification. CrossTransformers~\cite{crosstrans} compute the distances between spatially-corresponding features in the query and labeled samples for few-shot classifications. Our solution to the $k$-shot problem also draws connections to optimization-based methods since we learn a classifier that can directly classify structured representations with the Earth Mover’s Distance, which can benefit from the increasing number of support samples.
    为了实现这一目标,以前的大多数方法都将整个图像表示为特征空间中的一个数据点。也有一些利用局部特征进行预测的作品。例如,Lifchitz等人引用{dense}直接对每个局部特征进行预测,并融合它们的结果。Li etal~\cite{revisit}采用$k$-NN融合局部距离。交叉注意网络利用注意力机制来突出目标区域,并为少镜头分类生成判别特征。crostransformer ~\ \引用{crosstrans}计算查询中空间对应的特征与标记样本之间的距离,以实现少镜头分类。我们对$k$-shot问题的解决方案也与基于优化的方法联系在一起,因为我们学习了一种分类器,它可以直接用地球移动者的距离(Earth Mover’s Distance)对结构化表示进行分类,这可以从越来越多的支持样本中受益。
    我们的方法似乎可以设计成朝着分成一类的方向移动,但要基于局部纹理而不是语义(CLIP)

    Besides the two popular approaches, many other promising methods have also been proposed to tackle the few-shot classification problem, such as works based on graph theories~\cite{Kim_2019_CVPR,wDAE,graph,yang2020dpgn}, reinforcement learning~\cite{rl}, differentiable SVM~\cite{metaoptnet}, generative models~\cite{Generative,Imaginary,SchwartzNIPS18,Mehrotra2017,ZhangNIPS2018MetaGAN,Hallucination,shen2019learning,li2020adversarial,yang2021free}, transductive learning~\cite{rodriguez2020embedding,dhillon2019baseline,hu2020empirical,yue2020interventional,boudiaf2020transductive}, recurrent models~\cite{shyam2017attentive,lstmmeta}, self-supervised learning~\cite{su2020does,tian2020rethinking}, the recent capsule network~\cite{wu2020attentive}, and temporal convolutions~\cite{SNAIL}. Few-shot learning has also been investigated for other computer vision tasks, such as image segmentation~\cite{zhang2019canet,zhang2019pyramid,liu2020crnet} and object detection~\cite{yang2020contexttransformer}.
    除了这两种流行的方法外,许多有前途的方法也被提出来解决少镜头分类问题,如基于图论的工作~引用{Kim_2019_CVPR,wDAE,graph,yang2020dpgn},强化学习~引用{rl},可微SVM~引用{metaoptnet},生成模型~ \引用{生成,虚构的,SchwartzNIPS18、Mehrotra2017 ZhangNIPS2018MetaGAN,幻觉,shen2019learning, li2020adversarial, yang2021free},转换学习~ \引用{rodriguez2020embedding、dhillon2019baseline hu2020empirical, yue2020interventional, boudiaf2020transductive},复发模型~ \ {shyam2017attentive, lstmmeta},自我监督学习~引用{su2020does,tian2020rethinking},最近的胶囊网络~引用{wu2020},时间卷积~引用{SNAIL}。少镜头学习也被用于其他计算机视觉任务,如图像分割和目标检测。

    \textbf{Earth Mover’s Distance.} Earth Mover’s Distance (EMD) was originally proposed in~\cite{emd} as a metric for color and texture based image retrieval. EMD has the formulation of the well studied transportation problem in linear programming, and thus the global optimal matching can be found by solving a linear program. EMD has several desirable properties that make it a popular method to compare structured representations. First, EMD can generate a structural similarity without explicit alignment information. It extends the distance between single elements to the distance between sets or distributions. Second, the number of elements in the sets can vary and EMD allows for partial matching when the total weights of two sets are not equal. EMD has been widely applied to many areas. For example, Kusner \etal\ \cite{kusner2015word} use EMD to measure the similarity between two documents, which calculates the minimal cost to transfer the word embeddings in a document to the other for document classification. Wang and Chan~\cite{wang2014new} propose to represent the hand shapes and textures with superpixels and employ EMD to measure the dissimilarity between the hand gestures for gesture recognition. In~\cite{nikolentzos2017matching}, Nikolentzos \etal\ represent graph data as a set of vectors corresponding to the vertices and use EMD to determine the similarity of two graphs for graph comparison. Schulter \etal~\cite{schulter2017deep} solve the multi-object tracking problem with a network flow formulation that learns features for network-flow-based data association. Zhao \etal~\cite{zhao2008differential} propose to use the differential EMD to tackle the visual tracking problem based on the sensitivity analysis of the simplex method. Li \cite{li2013tensor} uses a tensor-SIFT based EMD to tackle the contour tracking problem.
    地球移动距离(EMD)最初是在~\ \引用{EMD}中提出的,作为一种基于颜色和纹理的图像检索度量非常适合纹理迁移这个任务,比CLIP更合适。EMD给出了线性规划中已被广泛研究的运输问题的公式,通过求解一个线性规划可以找到全局最优匹配。EMD有几个理想的属性,使其成为比较结构化表示的流行方法。首先,EMD可以在没有明确对齐信息的情况下生成结构相似度。它将单个元素之间的距离扩展到集合或分布之间的距离。其次,集合中的元素数量可能会变化,当两个集合的总权值不相等时,EMD允许进行部分匹配。EMD已被广泛应用于许多领域。例如,Kusner etal\ \ \ \cite{kusner2015word}使用EMD来度量两个文档之间的相似性,计算出将一个文档中的单词嵌入转移到另一个文档中进行文档分类的最小代价。Wang和Chan提出用超像素表示手的形状和纹理,并利用EMD度量手势之间的差异来进行手势识别。在~\cite{nikolentzos2017matching}中,Nikolentzos \etal\将图数据表示为顶点对应的一组向量,并使用EMD来确定两个图的相似度,以便进行图的比较。Schulter利用一种网络流公式解决了多目标跟踪问题,该公式学习了基于网络流的数据关联的特征。在单纯形法灵敏度分析的基础上,提出了利用差分EMD来解决视觉跟踪问题的方法。利用一种基于张量- sift的EMD方法来解决轮廓跟踪问题。

    \textbf{Parameterized optimization.} Parameterized optimization problems have a parameterized object function and constraints that depend on input data. Many previous works have investigated differentiation through the $\rm argmin$ operators. In \cite{gould2016differentiating}, Gould \etal present the methods for differentiation through optimization problems with only equality constraints. Agrawal \etal \cite{agrawal2019differentiating} propose a method that can compute the gradient of the solution with respect to the coefficients in the convex cone program, which can scale to large problems. Barratt \cite{barratt2018differentiability} describes the general case of using the implicit function theorem and interior point methods to compute the Jacobian of the solution with respect to the problem parameters. With the same theory, Amos and Kolter \cite{amos2017optnet} design a batched Quadratic Programming solver as a layer that can be integrated into a neural network for end-to-end training. In~\cite{agrawal2019differentiable}, Agrawal \etal\ propose a differentiable convex optimization layer that can differentiate through disciplined convex programs and allow users to define problems in a natural syntax without converting problems to canonical forms. Vlastelica \etal\ \cite{vlastelica2019differentiation} introduce the combinatorial building blocks into neural networks and the end-to-end trainable network can generate informative backward gradients through any black-box implementations of combinatorial solvers. Based on such building blocks, Rolínek~\etal~\cite{rolinek2020deep} design an end-to-end network that incorporates a combinatorial solver to solve the graph matching problem.
    \ textbf{参数化优化。参数化优化问题有一个参数化的对象函数和依赖于输入数据的约束。以前的许多工作已经研究了argmin算子的微分。在引用{gould2016微分}中,Gould etal提出了通过仅具有等式约束的优化问题进行微分的方法。Agrawal \etal \引用{agrawal2019微分}提出了一种方法,可以计算解的梯度相对于凸锥程序中的系数,这可以扩展到大型问题。Barratt \引用{barratt2018 .可微性}描述了使用隐函数定理和内点法计算问题参数解的雅可比矩阵的一般情况。使用相同的理论,Amos和Kolter(引用{amos2017optnet})设计了一个批处理二次规划求解器作为一个层,可以集成到神经网络中进行端到端训练。在引用{agrawal2019可微}的文章中,Agrawal等人提出了一个可微凸优化层,该层可以通过有规则的凸程序进行区分,并允许用户以自然语法定义问题,而无需将问题转换为规范形式。vlastelica2019differentiation}将组合构建块引入神经网络,端到端可训练网络可以通过组合求解器的任何黑盒实现生成信息丰富的向后梯度。在此基础上,Rolínek~ etal~引用{rolinek2020deep}设计了一个端到端网络,该网络包含了一个组合求解器来解决图匹配问题。

    image.png
    我们的1shot图像分类框架}。给定一对图像,我们首先提取它们的局部嵌入,这是两组特征向量。然后利用地球移动者的距离来生成两组之间的最优匹配流,该匹配流的总体匹配成本最小。最后,根据最优匹配流和匹配代价,计算出两幅图像之间的距离,用于分类。
    我们研究了三种提取局部嵌入的方法:完全卷积网络,基于网格的裁剪图像块;\textbf{(c)}随机采样图像补丁。这三个方法的详细信息在章节~\ref{sec:emd}中提供。 此处可以扩展一个ROI方法

    \section{Preliminary} Before presenting our algorithm in detail, we first introduce some preliminary concepts in the few-shot classification literature. The general meta-learning algorithm aims to learn transferable knowledge across tasks, where knowledge learned on training tasks can be used to solve novel tasks with only a small amount of training data. In the few-shot classification scenario, a task $\mathcal{T}i$ is to undertake classification over a set of sampled classes, characterized by scarce training images. Specifically, an $N$-way $K$-shot task denotes classification over $N$ classes with $K$ training samples in each class. To acquire generalization ability across tasks, the training and testing of the model are often aligned with the episodic paradigm~\cite{matchnet} where batched tasks are sampled for training or evaluation. For each sampled task, the training set $\mathcal{S}={(x^s_1,y^s_1),…,(x^s{NK},y^s{NK})}$ is called the \emph{support set} and the testing set $\mathcal{Q}={(x^q_1,y^q_1),…,(x^q{NKQ},y^q{NK_Q})}$ is called the \emph{query set}, where $x_i$ is an image, $y_i$ is its corresponding label, $y_i \in {1,…,N}$, and $K_Q$ is the number of testing images per class. At training time, the ground-truth label of the query sets provides learning supervision, and at inference time, we repeatedly sample tasks for evaluation and record their mean accuracy.
    在详细介绍算法之前,我们首先介绍了少数镜头分类文献中的一些初步概念。一般元学习算法的目标是跨任务学习可转移的知识,在训练任务中学习到的知识可以用少量的训练数据来解决新的任务。
    image.png
    image.png
    在训练时,查询集的ground-truth标签提供了学习监督,在推理时,我们重复采样任务进行评估,并记录其平均准确度。

    \section{Our Method}
    In this section, we first present a brief review of the Earth Mover’s Distance and describe how we formulate the one-shot classification as an optimal matching problem that can be trained end-to-end. Then, we describe our cross-reference mechanism to generate the weight of each node, which is an important parameter in the EMD formulation. Finally, we demonstrate how to use the EMD to tackle $k$-shot learning with our proposed structured fully connected layer. The overview of our framework for one-shot classification is shown in Fig.~\ref{fig:whole}.
    在本节中,我们首先简要回顾了地球移动者的距离,并描述了我们如何将一次分类作为一个可以端到端训练的最佳匹配问题来制定。然后,我们描述了我们的交叉引用机制来生成每个节点的权值,这是EMD公式中的一个重要参数。最后,我们演示了如何使用EMD来处理我们提出的结构化全连接层的$k$ shot学习。我们的一次性分类框架概述如图~\ref{Fig:whole}所示。

    \subsection{Revisiting the Earth Mover’s Distance }
    The Earth Mover’s Distance is a distance measure between two sets of weighted objects or distributions, which is built upon the basic distance between individual objects and the weight of each element. It has the form of the well-studied transportation problem from Linear Programming. Specifically, suppose that a set of sources or suppliers $\mathcal{S} = {si \; |\; i = 1,2,…m}$ are required to transport goods to a set of destinations or demanders $\mathcal{D} = {d_j\;|\;j = 1,2,…k}$, where $s_i$ denotes the supply units of supplier $i$ and $d_j$ represents the demand of $j$-th demander. The cost per unit transported from supplier $i$ to demander $j$ is denoted by $c{ij}$ , and the number of units transported is denoted by $x{ij}$. The goal of the transportation problem is then to find a least-expensive flow of goods $\tilde{\mathcal{X}} = {\tilde{x}{ij} \; | \; i = 1,… m, j = 1,… k}$ from the suppliers to the demanders: \begin{equation} \begin{aligned} & \underset{x{ij}}{\text{minimize}} & & \sum\nolimits{i=1}^{m}\sum\nolimits{j=1}^{k}c{ij}x{ij} \ & \text{subject to} & & x{ij}\geqslant 0, i=1,…,m,j=1,…,k\ &&&\sum\nolimits{j=1}^{k}x{ij} = si, ~ ~ i=1,…m \ &&&\sum\nolimits{i=1}^{m}x_{ij} = d_j, ~ ~ j=1,…k \ \end{aligned} \label{emd_ori} \end{equation} The roles of suppliers and demanders can be switched without affecting the total transportation cost. Here $s_i$ and $d_j$ are also called the weights of the nodes, which controls the total matching flows generated by each node. EMD seeks an optimal matching $\tilde{\mathcal{X}}$ between suppliers and demanders such that the overall matching cost can be minimized. The global optimal matching flows $\tilde{\mathcal{X}}$ can be achieved by solving a Linear Programming problem.
    地球移动距离是两组加权对象或分布之间的距离度量,它建立在单个对象之间的基本距离和每个元素的权重上。
    它具有线性规划中已被充分研究的运输问题的形式。
    image.png

    image.png
    image.png

    在不影响总运输成本的情况下,供应商和需求方的角色可以互换。这里$s_i$和$d_j$也称为节点的权值,它们控制每个节点生成的总匹配流。EMD寻求供应商和需求方之间的最优匹配$ tilde{\mathcal{X}}$,使总体匹配成本最小化。通过求解一个线性规划问题,可以得到全局最优匹配流$ tilde{mathcal{X}}$。

    \subsection{EMD for Few-Shot Classification} \label{sec:emd}

    In the few-shot classification task, metric-based methods aim to find a good distance metric and data representations to compute the distance between images, which are used to compare images for classification. Different from the previous methods~\cite{proto,matchnet} that perform distance computation between the image-level embeddings, our approach advocates the use of discriminative local information. % The intuition is that as the goal of few-shot learning is to undertake the classification task on novel categories, directly generating a category-level embedding that corresponds to a new class is difficult. On the other hand, we can decompose an object into a set of object parts that may have been seen in the training process. For example, \emph{wheel} can be a shared building element across vehicle categories, and if such representation is learned during training, it can be useful to classify unseen vehicle categories. Therefore, local discriminative representations are likely to provide more transferable information across categories. % In our framework, we decompose images into a set of local representations, and by assigning appropriate weights to local embeddings in two images, we can use the optimal matching cost between them to represent their dissimilarity. % We explore three strategies to generate local representations from an image, as illustrated in Fig.~\ref{fig:whole}:\
    在少镜头分类任务中,基于度量的方法旨在找到一个良好的距离度量和数据表示来计算图像之间的距离,用于比较图像进行分类。与之前的方法~ cite{proto,matchnet}执行图像级嵌入之间的距离计算不同,我们的方法提倡使用有区别的局部信息。直觉上,由于少射击学习的目标是承担新类别的分类任务,直接生成对应于新类别的类别级嵌入是困难的。另一方面,我们可以将一个对象分解为一组可能在训练过程中看到的对象部分。例如,\emph{wheel}可以是跨车辆类别的一个共享的建筑元素,如果在培训期间学习了这种表示,它可以对未见过的车辆类别进行分类。因此,局部区别表示有可能提供更多跨类别的可转移信息。在我们的框架中,我们将图像分解为一组局部表示,通过为两幅图像中的局部嵌入分配适当的权重,我们可以使用它们之间的最优匹配代价来表示它们的不相似性。%我们探索了三种从图像中生成局部表示的策略,如图所示~ ref{Fig:whole}:\

    1) \textbf{Fully Convolutional Networks.} We can deploy a fully convolutional network (FCN)~\cite{fcn} to generate the dense representation $\mathbf{U} \in \mathbb{R}^{H \times W \times C}$ of an image, where $H$ and $W$ denote the spatial size of the feature map and $C$ is the feature dimension. Each image representation contains a collection of local feature vectors ${\mathbf{u}1,\mathbf{u}_2,…\mathbf{u}{HW}}$, and each vector $\mathbf{u}i$ can be seen as a node in the set. Thus, the dissimilarity of two images can be represented as the optimal matching cost between two sets of vectors.
    1)完全卷积网络。我们可以部署一个全卷积网络(FCN)~引用{FCN}来生成图像在mathbb{R}^{H \ × W \ × C}$中的密集表示$ mathbf{U} \,其中$H$和$W$表示特征图的空间大小,$C$为特征维数。每个图像表示包含一个局部特征向量的集合$ {mathbf{u}_1,\mathbf{u}_2,…\mathbf{u}
    {HW}}$,每个向量$\mathbf{u}_i$可以看作集合中的一个节点。因此,两幅图像的不相似性可以表示为两组向量之间的最优匹配代价。

    2) \textbf{Dividing the input image into grids.} We crop the image evenly into an $H \times W$ grid before feeding it to the CNN, and each image patch in the grid cell is encoded by the CNN individually and generates a feature vector. The feature vectors generated by all the patches constitute the embedding set of an image.
    2) \textbf{将输入图像划分为网格。我们将图像均匀地裁剪成$H \ × W$网格,然后将其输入CNN,网格单元中的每个图像patch由CNN单独编码并生成一个特征向量。由所有的patches生成的feature vector构成图像的嵌入集合。

    3) \textbf{Random sampling of image patches.} Instead of generating the image patches by grids, here we randomly sample $M$ patches in the images with different sizes and aspect ratios. The randomly sampled patches are then re-scaled to the same input size and are encoded by CNNs. The embeddings of these sampled patches make up the embedding set of an image.
    3) \textbf{图像补丁的随机采样。在这里,我们不是通过网格生成图像补丁,而是在不同大小和宽高比的图像中随机抽取$M$补丁。然后将随机采样的patch重新缩放到相同的输入大小,并由cnn进行编码。这些样本块的嵌入构成一幅图像的嵌入集。

    We denote our networks adopting the three strategies above by \textit{DeepEMD-FCN}, \textit{DeepEMD-Grid}, and \textit{DeepEMD-Sampling}, respectively. As the size of the grid in DeepEMD-Grid and the number of patches in DeepEMD-Sampling are hyper-parameters in our network, we conduct various experiments to investigate the influence of these parameters in Section~\ref{sec:ablation}. We also investigate pyramid structures on the image level and the feature level to capture local representations at multiple scales, illustrated in Fig.~\ref{fig:pyramid}. Specifically, we add a feature pyramid structure to DeepEMD-FCN and an image pyramid structure to DeepEMD-Grid. The feature pyramid applies the RoI pooling to the feature maps generated by the FCN, and the resulting feature vectors together with the raw feature vectors constitute the embedding set. For the image pyramid, we simply crop the patches according to different grid sizes and send all patches to the CNN to generate the embedding set.
    我们分别用\textit{DeepEMD-FCN}、\textit{DeepEMD-Grid}和\textit{DeepEMD-Sampling}表示我们采用上述三种策略的网络。由于DeepEMD-Grid中的网格大小和DeepEMD-Sampling中的patch数量是我们网络中的超参数,我们在~\ref{sec:消融}章节中进行了各种实验来研究这些参数的影响。我们还研究了图像级和特征级的金字塔结构,以捕获多个尺度上的局部表示,如图所示。具体来说,我们在DeepEMD-FCN中增加了特征金字塔结构,在DeepEMD-Grid中增加了图像金字塔结构。特征金字塔对FCN生成的特征图进行RoI池化,得到的特征向量与原始特征向量构成嵌入集。对于图像金字塔,我们只需根据不同的网格大小裁剪patches,并将所有patches发送给CNN生成嵌入集。

    After acquiring the embedding sets of two images, we can follow the original EMD formulation in Equation~\eqref{emdori} to compute the distance. Concretely, assuming there are $H \times W$ vectors in each set, the cost per unit is obtained by computing the pairwise distance between embedding nodes $\mathbf{u}_i$, $\mathbf{v}_j$ from two image features: \begin{equation} c{ij}=1-\frac{{\mathbf{u}i}^T \mathbf{v}_j}{\lVert \mathbf{u}_i\rVert \lVert \mathbf{v}_j\rVert}, \label{cost} \end{equation} where nodes with similar representations tend to generate small matching costs between each other. As to the generation of weights $s_i$ and $d_j$, we leave the detailed elaborations in Section~\ref{sec_weight_generation}. Once acquiring the optimal matching flows $\tilde{\mathcal{X}}$, we can compute the similarity score $s$ between image representations with: \begin{equation} s(\mathbf{U},\mathbf{V})=\sum{i=1}^{HW}\sum{j=1}^{HW}(1-c{ij})\tilde{x}_{ij}. \end{equation}
    在获取两幅图像的嵌入集后,我们可以按照公式~\eqref{emd_ori}中原始的EMD公式计算距离。具体来说,假设每个集合中有$H \ × W$向量,单位代价由两个图像特征分别计算嵌入节点的成对距离
    image.png
    表示具有相似表示形式的节点之间往往产生较小的匹配代价。至于权重$s_i$和$d_j$的生成,我们将在~\ref{sec_weight_generation}节中详细阐述。
    一旦获得最优匹配流$\tilde{mathcal{X}}$,我们就可以用以下方法计算图像表示之间的相似度
    image.png

    \subsection{End-to-End Training}

    In order to embed the optimal matching problem into a neural network for end-to-end training, it is important to make the solution of the optimal matching $\tilde{\mathcal{X}}$ differentiable with respect to the problem parameter $\theta$. As is indicated by \cite{barratt2018differentiability}, we can apply the implicit function theorem \cite{barratt2018differentiability,dontchev2009implicit,krantz2012implicit} on the optimality (KKT) conditions to obtain the Jacobian. For the sake of completeness, we transform the optimization in Equation~\eqref{emd_ori} to a compact matrix form:

    % \begin{equation} \begin{aligned} & \underset{x}{\text{minimize}} & & c(\theta)^Tx \ & \text{subject to} & & G(\theta)x \leqslant h(\theta),\ &&& A(\theta)x=b(\theta).\ \end{aligned} \label{lp} \end{equation}

    Here $x \in \mathbb{R}^n$ is our optimization variable, with $n = m \times k$ representing the total number of matching flows in $\mathcal{X}$. $\theta$ is the problem parameter that relates to the earlier layers in a differentiable way. $Ax = b$ represents the equality constraints and $Gx \leqslant h$ denotes the inequality constraint in Equation~\eqref{emdori}. \input{sub_content/4_sparse_matrix} Accordingly, the Lagrangian of the LP problem in Equation~\eqref{lp} is given by: \begin{equation} \begin{aligned} L(\theta,x,\nu ,\lambda) = c^Tx + \lambda^T(Gx-h)+ \nu^T(Ax-b), \end{aligned} \end{equation} where $\nu$ denotes the dual variables on the equality constraints and $\lambda \geqslant 0$ denotes the dual variables on the inequality constraints. Following the KKT conditions with notational convenience, we can obtain the optimum $(\tilde{x},\tilde{\nu},\tilde{\lambda})$ of the objective function by solving $g(\theta,\tilde{x},\tilde{\nu},\tilde{\lambda}) = 0$ with primal-dual interior point methods, where \begin{equation} g(\theta, x,\nu,\lambda) = \begin{bmatrix} \nabla\theta L(\theta,x,\nu,\lambda) \ \textbf{diag}(\lambda)(G(\theta)x-h(\theta)) \ A(\theta)x-b(\theta) \end{bmatrix}. \end{equation} Then, the following theorem holds to help us derive the gradients of the LP parameters.\ \textbf{Theorem 1} (From Barratt \cite{barratt2018differentiability}) Suppose $g(\theta,\tilde{\lambda},\tilde{\nu},\tilde{x}) = 0$. Then, when all derivatives exist, the partial Jacobian of $\tilde{x}$ with respect to $\theta$ at the optimal solution $(\tilde{\lambda},\tilde{\nu},\tilde{x})$, namely $J\theta \tilde{x}$, can be obtained by satisfying:% \begin{equation}% \begin{aligned} J\theta \tilde{x} =& -Jx g(\theta,\tilde{\lambda},\tilde{\nu},\tilde{x})^{-1}J\theta g(\theta,\tilde{x},\tilde{\nu},\tilde{\lambda}).% \end{aligned} \end{equation} Here the formula for the Jacobian of the solution mapping is obtained by applying the implicit function theorem to the KKT conditions. For instance, the (partial) Jacobian with respect to $\theta$ can be defined as \begin{equation} J\theta g(\theta,\tilde{\lambda},\tilde{\nu},\tilde{x}) = \begin{bmatrix} J\theta \nablax L(\theta,\tilde{x},\tilde{\nu},\tilde{\lambda}) \ \textbf{diag}(\tilde{\lambda})J\theta (G(\theta)x-h(\theta)) \ J_\theta (A(\theta)\tilde{x}-b(\theta)) \end{bmatrix}. \end{equation} Therefore, once getting the optimal solution $\tilde{x}$ for the LP problem, we can obtain a closed-form expression for the gradient of $\tilde{x}$ with respect to the input LP parameters $\theta$. This helps us achieve an efficient backpropagation through the entire optimization process without perturbation of the initialization and optimization trajectory. \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{pyramid.pdf} \caption{ Pyramid structures applied on DeepEMD-FCN and DeepEMD-Grid to extract local embeddings. The feature pyramid structure (a) adopts RoI poolings with different output sizes on the feature maps to generate local embeddings at multiple scales while the image pyramid structure (b) crops the input image into patches according to different grid sizes, and all patches are sent to the CNN to generate local embeddings.} \label{fig:pyramid} \end{figure} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{SFC.pdf} \caption{ Comparison of the standard fully connected layer \textbf{(a)} and our proposed structured fully connected layer (SFC) \textbf{(b)}. The SFC learns a group of vectors as the prototype for each class such that we can use the EMD to generate category scores. } \label{fig:SFC} \end{figure}

    \subsection{Weight Generation}

    \label{secweight_generation} As can be observed in the EMD formulation, an important problem parameter is the weight of each node, \eg, $s_i$, which controls the total matching flows $\sum{j=1}^{k}x{ij} $ from it. Intuitively, the node with a larger weight plays a more important role in the comparison of two sets, while a node with a very small weight can hardly influence the overall distance no matter which nodes it connects with. In the pioneering work that adopts EMD for color-based image retrieval~\cite{emd}, they use the histogram as the elementary feature and perform feature clustering over all pixels to generate the nodes. The weight of each node is set as the size of the corresponding cluster. It makes sense because, for color-based image retrieval, large weights should be assigned to the dominant colors with more pixels, such that the retrieved images can be visually close to the query images. However, for few-shot image classification tasks where features for classification often contain high-level semantic information, the number of pixels does not necessarily reflect the importance. It is common to find image data with greater background regions than the target objects in classification datasets, \eg, ImageNet. Therefore, large weights should be given to the foreground object region in a matching algorithm. However, it may be difficult to define what is the foreground region, particularly when there exist multiple object categories in a single image. An object can be both foreground and background in different cases. Instead of determining the weights by inspecting individual images alone, we argue that for the few-shot classification task, the co-occurrent regions in two images are more likely to be the foreground and the weights of node features should be generated by comparing the nodes on both sides. To achieve this goal, we propose a cross-reference mechanism that uses dot product between a node feature and the average node feature in the other structure to generate a relevance score as the weight value: \begin{equation} s_i= \max \Bigl{ \mathbf{u}_i^T\cdot\frac{\sum{j=1}^{HW}{\mathbf{v}j}}{HW},0 \Bigr}, \end{equation} where $\mathbf{u}_i$ and $\mathbf{v}_j$ denote the vectors from two feature maps, and function $max(\cdot)$ ensures the weights are always non-negative. Finally, we normalize all the weights in the structure to make both sides have the same total weights for matching: \begin{equation} \label{eq:norm} \hat{s}_i=s_i\frac{HW}{\sum{j=1}^{HW}{sj}}. % \end{equation} For simplicity, here we take $s_i$ as an example and $d_i$ can be obtained in the same manner. The cross-reference mechanism aims to give less weight to the high-variance background regions and more to the co-occurrent object regions in two images. This can also put less weight on the object parts that do not co-occur in two images and thus allows partial matching to some extent. As a result, the proposed distance metric is based only on confident regions and confident features that have high responses. \subsection{Structured Fully Connected Layer} Thus far we have discussed using the Earth Mover’s Distance as the metric to generate the distance value between paired images, \ie, the one-shot case. A question is then raised—-how do we tackle the $k$-shot setting where multiple support images are available? Before presenting our design in detail, let us revisit how the standard fully connected layer classifies an image embedding extracted by CNNs. An FC layer, parameterized by $[{\bf{\Phi}}_1,…, {\bf{\Phi}}_N]\in \mathbb{R}^{C\times N}$ contains a set of learnable vectors ${\bf{\Phi}}_i\in \mathbb{R}^{C}$ corresponding to each category. Given an image embedding $\mathbf{u}\in \mathbb{R}^{C}$ generated by the convolutional layer, the FC layer generates the score of class $i$ by computing the dot product between the image vector $\mathbf{u}$ and the parameter vector ${\bf{\Phi}}_i$, and this process is applied to all the categories in parallel by matrix multiplication. There are also some previous works replacing the dot product operation in the FC layer with the \emph{cosine} function for computing the category scores~\cite{closer,weightnorm}. The learning of the FC layer can be seen as finding a prototype vector for each class such that we can use distance metrics to classify an image. An illustration of the standard FC layer is shown in Fig.~\ref{fig:SFC} (a). With the same formulation, we can learn a structured fully connected layer that adopts EMD as the distance function to directly classify a structured feature representation. The learnable parameter for each class becomes a group of vectors, rather than one vector, such that we can use the structural distance function EMD to undertake image classification. This can also be interpreted as learning a prototype feature map generated by a dummy image for each class. The comparison of the structured FC and the standard FC can be found in Fig.~\ref{fig:SFC}. Algorithm~\ref{alg:episode} provides the pseudo-code of a testing episode at inference time. We fix the network backbone and use SGD to learn the parameters in the structured fully connected layer by sampling data from the support set. After several iterations of optimization, we can generate the category scores by computing the EMD between the query images and each of the prototypes in the SFC. \begin{algorithm}[t] \caption{A testing episode for an $N$-way $K$-shot task. $N{iter}$ is the number of optimization iterations.} \label{alg:episode} \SetAlgoLined \SetKwInput{KwData}{Input} \SetKwInput{KwResult}{Output} \KwData{a trained feature extractor $\Theta$, the support set $\mathcal{S}$, and the query set $\mathcal{Q}$} \KwResult{Testing accuracy $Acc$ of query set.} Initialize SFC layer: $\Phi=\Phi’$\; \For{i \textbf{from} 1 \textbf{to} $N{iter}$}{ Sample a mini-batch $\mathcal{B}_i$ from S\; make predictions for $\mathcal{B}_i$ with our model $[\Theta, \Phi]$\; calculate cross entropy loss $\mathcal{L}{\mathcal{T}}$\; optimize $\Phi$ with SGD\; } make predictions for images in the query set $\mathcal{Q}$\ with the model $[\Theta, \Phi]$\; calculate accuracy $Acc$\; return $Acc$. \end{algorithm} % \vspace{-6mm}