Siamese nets are typically trained on a collection of similar ( positive ) and dissimilar ( negative ) pairs of data points . When labeled data are available , such pairs can be chosen based on label information ( i.e. , pairs of points with the same label are considered positive , while pairs of points with different labels are considered negative ) . Here we focus on datasets that are unlabeled . In this case we can learn the affinities directly from Euclidean proximity or from graph distance , e.g. , by " labeling " points x i , x j positive if x i − x j is small and negative otherwise . In our experiments , we construct positive pairs from the nearest neighbors of each point . Negative pairs are constructed from points with larger distances . This Siamese network , therefore , is trained to learn an adaptive nearest neighbor metric .