Distance-metric learning is an old problem that has been researched in the supervised-learning field for a very long time. In this paper, we consider the problem of learning a proper distance metric under the guidance of some weak supervisory information. Specifically, this information is in the form of pairwise constraints which specify whether a pair of data points is in the same class ( must-link constraints) or in different classes ( cannot-link constraints). Given those constraints, our algorithm aims to learn a distance metric under which the points with must-link constraints are pushed as close as possible, while simultaneously, the points with cannot-link constraints are pulled away as far as possible. The kernelized version of our algorithm is also derived to tackle the nonlinear problem. Moreover, since in many cases, the data objects, such as images and videos, are more naturally represented as higher order tensors than vectors, we also extend our algorithm to learn the metrics directly from the tensors. Finally, experimental results are presented to show the effectiveness of our method. © 2011 IEEE.