本次代码的作者是:
(C) Laurens van der Maaten, Delft University of Technology
thanks,it is very helpful. I am trying to interprete this code.
代码加注释:
function [M, L, Y, C] = lmnn(X, labels)
%LMNN Learns a metric using large-margin nearest neighbor metric learning
%
% [M, L, Y, C] = lmnn(X, labels)
%
% The function uses large-margin nearest neighbor (LMNN) metric learning to
% learn a metric on the data set specified by the NxD matrix X and the
% corresponding Nx1 vector labels. The metric is returned in M.
%
%
% This file is part of the Matlab Toolbox for Dimensionality Reduction.
% The toolbox can be obtained from http://homepage.tudelft.nl/19j49
% You are free to use, change, or redistribute this code in any way you
% want for non-commercial purposes. However, it is appreciated if you
% maintain the name of the original author.
%
% (C) Laurens van der Maaten, Delft University of Technology
% Initialize some variables
[N, D] = size(X);
%如果不满足assert的条件就会退出
assert(length(labels) == N);
%获取所有种类,lablist里面存储的是所有的label种类
[lablist, ~, labels] = unique(labels);
%一共有多少种类
K