{"task": {"agent_timeout": 3600, "task": "gps_chamfer_distance", "verifier_timeout": 120, "instruction": "You are an expert in reproducing research code from a paper.\n\n## Paper Content\nHere is the paper that you need to use to complete the code:\n<paper>\n# GPS: A Probabilistic DistributiOnal Similarity WITH GUMBEL PRIORS FOR SET-TO-SET MATCHING \n\nZiming Zhang ${ }^{1}$, Fangzhou Lin ${ }^{1}$, Haotian Liu ${ }^{1}$, Jose Morales ${ }^{1}$, Haichong Zhang ${ }^{1}$, Kazunori Yamada ${ }^{2}$, Vijaya B Kolachalama ${ }^{3}$, Venkatesh Saligrama ${ }^{3}$<br>${ }^{1}$ Worcester Polytechnic Institute, USA ${ }^{2}$ Tohoku University, Japan ${ }^{3}$ Boston University, USA<br>\\{zzhang15, fliin2, hliu8, jamorales, hzhang10\\}@wpi.edu<br>yamada@tohoku.ac.jp, \\{vkola, srv\\}@bu.edu\n\n\n#### Abstract\n\nSet-to-set matching aims to identify correspondences between two sets of unordered items by minimizing a distance metric or maximizing a similarity measure. Traditional metrics, such as Chamfer Distance (CD) and Earth Mover's Distance (EMD), are widely used for this purpose but often suffer from limitations like suboptimal performance in terms of accuracy and robustness, or high computational costs - or both. In this paper, we propose an effective set-to-set matching similarity measure, GPS, based on Gumbel prior distributions. These distributions are typically used to model the extrema of samples drawn from various distributions. Our approach is motivated by the observation that the distributions of minimum distances from CD, as encountered in real-world applications such as point cloud completion, can be accurately modeled using Gumbel distributions. We validate our method on tasks like few-shot image classification and 3D point cloud completion, demonstrating significant improvements over state-of-the-art loss functions across several benchmark datasets. Our demo code is publicly available at [GitHub link removed]\n\n\n## 1 INTRODUCTION\n\nProblem. Set-to-set matching involves comparing and identifying correspondences between two sets of items, which can be modeled as a bipartite graph matching problem. In this framework, the items in each set are represented as nodes on opposite sides of a bipartite graph, with the edges representing the correspondences. This task is challenging due to several factors: (1) The matching process must be invariant to the order of both the sets and the items within them; (2) Finding effective representations for each set is critical, as it greatly influences performance; (3) Computing a meaningful similarity score between sets, often used as a loss function for learning feature extractors, is a nontrivial problem. Our goal is to develop a similarity measure that is both effective and efficient for set-to-set matching.\n\nDistance Metrics. Set-to-set matching has been extensively studied in various research fields (Chang et al., 2007; Zhou et al., 2017a; Saito et al., 2020; Jurewicz and Derczynski, 2021; Yu et al., 2021a; Kimura et al., 2023). Several distance metrics, such as Chamfer Distance (CD) (Yang et al., 2020), Earth Mover's Distance (EMD) (Zhang et al., 2020a; Yang et al., 2024), and Wasserstein Distance (WD) (Zhu and Koniusz, 2022), are commonly used to evaluate set-matching scores in different applications. These metrics can generally be considered special cases of optimal transportation (OT) for graph matching (Saad-Eldin et al., 2021), which aims to find the most efficient way to move a distribution of \"materials\" to another distribution of \"consumers\" by minimizing the total transportation cost. However, it is well known that these distance metrics often face challenges such as poor performance (e.g., matching accuracy and robustness of CD (Lin et al., 2023a)) or high computational complexity (e.g., EMD and WD (Nguyen et al., 2021; Rowland et al., 2019; Kolouri\n\n[^0]\n[^0]:    *First co-author, project leader\n    ${ }^{\\dagger}$ First co-author, responsible for experiments on point cloud completion\n    ${ }^{\\ddagger}$ First co-author, responsible for experiments on few-shot classification\net al., 2019)), or both, which limit their applicability in large-scale learning. To address this issue, some new distance metrics, such as density-aware CD (DCD) (Wu et al., 2021), HyperCD (Lin et al., 2023b) and InfoCD (Lin et al., 2023a), have been developed as training losses in the literature to improve matching performance while achieving linear complexity similar to CD.\n\nLimitations of Traditional Distance Metrics. Existing metrics fail to adequately capture the similarity between sets in terms of their underlying distributions. In many real-world applications, such as classification, the primary concern is not the direct similarity between individual data instances but rather their similarity in some (latent) space, such as class labels.\n\nFor instance, in Figure 1 in the context of Chamfer Distance (CD), the distance between the sets $\\circ$ and $\\times$ is larger than that between the sets $\\circ$ and + , despite $\\circ$ and $\\times$ being sampled from the same underlying distribution. This highlights a critical issue: when asking \"how likely are two sets of points to come from the same distribution?\" CD and similar metrics may fail to reflect distributional similarity accurately. Consequently, traditional distance metrics are effective at measuring differences in observations (e.g., point clouds or images) but may struggle to capture deeper, potentially unknown abstractions such as distributions or class labels.\n![img-0.jpeg](img-0.jpeg)\n\nFigure 1: Illustration of three point sets randomly sampled from a circular distribution (i.e., Distr. 1) and a Gaussian whose mean is conditional on the circle (i.e., Distr. 2).\n\nDistributional Similarity. This concept is widely applied in natural language processing to assess word similarities based on the contexts in which they appear (Lee, 2000). For example, to measure the similarity between words $u$ and $v$, both words can be represented in a vector space by counting their co-occurrences with words from a predefined vocabulary within local contexts such as sentences or paragraphs. Various similarity functions are then applied to these vectors to compute their similarity. To adapt this idea for set-to-set matching, we treat the K nearest neighbors (KNNs) of a point from the opposite set as its \"co-occurrences\".\n\nGumbel Distributions. In probability theory, Gumbel distributions are used to model the distribution of extreme values (maxima or minima) from various samples. We find that Gumbel distributions effectively model the KNN distances between two sets of feature vectors. This is shown in Figure 2, where the two 2D point sets are sampled from the circular distribution shown in Figure 1. We compute the negative-log distances between each point in one set and its 1st, 2nd, and 3rd nearest neighbors in the other set, transforming these distances into normalized histograms representing probabilities. These probability distributions are then fitted with Gumbel distributions (see Definition 1).\n![img-1.jpeg](img-1.jpeg)\n\nFigure 2: Data fitting with Gumbel distributions for 1st, 2nd, 3rd smallest distance distributions between two 2D point sets.\n\nOur Approach and Contributions. We propose a novel probabilistic method for set-to-set matching called GPS (Gumbel Prior Similarity) based on distributional similarity and Gumbel distributions. This method measures the similarity between the underlying distributions generating the sets. Specifically, we use the log-likelihood of Gumbel distributions as our similarity measure, modeling the distributions of negative-log distances between the KNNs of the sets. GPS can be seamlessly integrated into existing neural network training frameworks, for instance, by using the negative of GPS as a loss function, while maintaining the same linear computational complexity as CD. We propose a comprehensive analysis of GPS and its influence on learning behavior. We are the first to leverage statistical information from KNNs for set-to-set matching. To demonstrate the efficacy and efficiency of GPS, we conduct extensive experiments on tasks such as few-shot image classification and 3D point cloud completion, achieving state-of-the-art performance across several benchmark datasets.\n# 2 RELATED WORK \n\nSet-to-Set Matching. Many tasks in computer vision and machine learning, such as multiple instance learning (Ilse et al., 2018; Maron and Lozano-P\u00e9rez, 1997), shape recognition (Su et al., 2015; Shi et al., 2015), and few-shot image classification (Afrasiyabi et al., 2022), can be framed as set-to-set matching problems, where the goal is to identify correspondences between sets of instances. The unordered nature of these sets requires the extraction of invariant features that are not affected by the sequence of elements (Choi et al., 2018). Some research addresses this challenge by modifying neural network architectures. For example, Vinyals et al. (2016) introduced matching networks for one-shot learning, while Lee et al. (2019) proposed the Set Transformer, which uses an attentionbased mechanism to model interactions among elements in input sets. Saito et al. (2020) developed exchangeable deep neural networks. Recently, Kimura (2022) analyzed the generalization bounds for set-to-set matching with neural networks. The loss function for training these networks must also maintain order-invariance to effectively calculate distance functions between pairs of instances within the sets, as seen in DeepEMD (Zhang et al., 2020a).\n\nSimilarity (Metric) Learning. This research focuses on developing functions that measure the correlation between two objects (Ma and Manjunath, 1996; Balcan and Blum, 2006; Yu et al., 2008), and has been successfully applied to various applications, including face recognition (Faraki et al., 2021; Cao et al., 2013), few-shot image classification (Zhang et al., 2020a; Oh et al., 2022), emotion matching (Lin et al., 2016), and re-identification (Zhou et al., 2017a; Liao et al., 2017). Recently, these techniques have been integrated into deep learning (Liu et al., 2019; Cheng et al., 2018; Ma et al., 2021; Liao et al., 2017; Zhou et al., 2017b) for representation learning in embedding spaces, where objects from the same set are closer together, and objects from different sets are further apart. However, learning a model from all sample pairs is challenging due to high computational complexity and poor local minima during training (Kaya and Bilge, 2019; Qian et al., 2019; Huang et al., 2016). Thus, designing effective and efficient loss functions is a key issue in deep similarity learning (Elezi et al., 2020; Wang et al., 2019). In contrast, we address this problem by utilizing the statistics of minimum distances between the items of sets to improve computational efficiency and performance.\n\nFew-Shot Classification. This task aims to train a classifier to recognize both seen and unseen classes with limited labeled examples (Chen et al., 2019a). During training, the model learns a generalized classification ability in varying classes (Oreshkin et al., 2018; Finn et al., 2017). In the testing phase, when presented with entirely new classes, the model classifies by calculating the closest similarity measurement (Chen et al., 2019a; Naik and Mammone, 1992). Formally, in few-shot learning, the training set includes many classes, each with multiple samples (Li et al., 2018; Ren et al., 2018). For example, $C$ classes are randomly selected from the training set and $K$ samples from each category (totaling $C \\times K$ samples) are used as input to the model. A batch of samples from the remaining data in these $C$ classes is then used as the model's prediction target (batch set). The model must learn to distinguish these $C$ classes from $C \\times K$ pieces of data, a task known as a $C$-way $K$-shot problem.\n\nPoint Cloud Completion. This task involves an important objective of inferring the complete shape of an object or scene from incomplete raw point clouds. Recently, numerous deep learning approaches have been developed to address this problem. For example, PCN (Yuan et al., 2018) extracts global features directly from point clouds and generates points using the folding operations from FoldingNet (Yang et al., 2018). Zhang et al. (2020b) proposed extracting multiscale features from different network layers to capture local structures and improve performance. Attention mechanisms, such as the Transformer (Vaswani et al., 2017), excel in capturing long-term interactions. Consequently, SnowflakeNet (Xiang et al., 2021), PointTr (Yu et al., 2021b), and SeedFormer (Zhou et al., 2022) emphasize the decoder component by incorporating Transformer designs. PointAttN (Wang et al., 2022) is built entirely on Transformer foundations. Recently, Lin et al. (2023b) introduced a HyperCD loss for training neural networks that defines traditional CD in a hyperbolic space. Furthermore, Lin et al. (2023a) proposed an InfoCD loss by incorporating the contrastive concept into the CD formula.\n\nGumbel Distribution. In machine learning and computer vision, the Gumbel distribution has been widely used in sampling methods (Maddison et al., 2014; Kool et al., 2019) and reparameterization techniques (Huijben et al., 2022; Kusner and Hern\u00e1ndez-Lobato, 2016; Potapczynski et al., 2020). For example, Hancock and Khoshgoftaar (2020) introduced the Gumbel-Softmax reparameterization to enable differentiable sampling from a discrete distribution during backpropagation in neural networks.\n# 3 APPROACH \n\n### 3.1 Preliminaries\n\nNotations \\& Problem Definition. We denote $\\mathcal{X}_{1}=\\left\\{x_{1, j}\\right\\} \\sim \\mathcal{P}_{1}, \\mathcal{X}_{2}=\\left\\{x_{2, j}\\right\\} \\sim \\mathcal{P}_{2}$ as two sets of points (or items) that are sampled from two unknown distributions $\\mathcal{P}_{1}, \\mathcal{P}_{2}$, respectively, and $K$ as the number of nearest neighbors considered for each point. Also, we refer to $|\\cdot|$ as the cardinality of a set, and $\\|\\cdot\\|$ as the $\\ell_{2}$-norm of a vector. Given these notations, our goal is to predict the set-to-set similarity, $\\kappa\\left(\\mathcal{X}_{1}, \\mathcal{X}_{2}\\right)$, based on the conditional probability $p\\left(\\mathcal{P}_{1}=\\mathcal{P}_{2} \\mid \\mathcal{X}_{1}, \\mathcal{X}_{2}\\right)$.\n\nGumbel Distributions. Recall that the Gumbel distribution is used to model the distribution of the maximum (or minimum by replacing the maximum with the negative of minimum) of a number of samples from various distributions. Here we list the definition of a Gumbel distribution as follows:\nDefinition 1 (Gumbel Distribution). The probability density function (PDF) of a Gumbel distribution with parameters $\\mu \\in \\mathbb{R}, \\sigma>0$, denoted as $\\operatorname{Gumbel}(\\mu, \\sigma)$, for a random variable $x \\in \\mathbb{R}$ is defined as\n\n$$\np(x)=\\frac{1}{\\sigma} \\exp \\{-(y+\\exp \\{-y\\})\\}, \\text { where } y=\\frac{x-\\mu}{\\sigma}\n$$\n\n### 3.2 GPS: Gumbel Prior Similarity for Set-to-Set Matching\n\nDistributional Signatures. Given two sets of points $\\mathcal{X}_{1}, \\mathcal{X}_{2}$, we define the set of Euclidean distances from each point in one set to its KNNs in the other set as their distributional signature:\n$\\mathcal{D}\\left(\\mathcal{X}_{1}, \\mathcal{X}_{2}\\right)=\\left\\{d_{\\min }^{(k)}\\left(x_{1, i}\\right)=\\left\\|x_{1, i}-x_{2, i_{k}}\\right\\|, d_{\\min }^{(k)}\\left(x_{2, j}\\right)=\\left\\|x_{2, j}-x_{1, j_{k}}\\right\\| \\mid \\forall k \\in[K], \\forall i, \\forall j\\right\\}$\nwhere $i_{k}$ (resp. $j_{k}$ ) denotes the index of the $k$-th nearest neighbor in $\\mathcal{X}_{2}$ (resp. $\\mathcal{X}_{1}$ ) for $x_{1, i}$ (resp. $x_{2, j}$ ), leading to an unordered set of $K\\left(\\left|\\mathcal{X}_{1}\\right|+\\left|\\mathcal{X}_{2}\\right|\\right)$ values.\n\nProbabilistic Modeling. To compute GPS, we introduce the Gumbel distributions and distributional signatures as latent variables, as shown in Figure 3, and propose a probabilistic framework as follows:\n\n$$\n\\begin{aligned}\np\\left(\\mathcal{P}_{1}=\\mathcal{P}_{2} \\mid \\mathcal{", "memory": "", "runnable": false, "difficulty": "difficult", "language": "", "cpus": "", "instruction_truncated": true, "category": "code-generation", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "research-code-bench", "tags": ["research-code-bench", "paper2code", "iclr2025", "GPS"]}, "runs": []}