mirror of
https://github.com/zhunzhong07/person-re-ranking.git
synced 2025-06-03 14:59:19 +08:00
21 lines
441 B
Mathematica
21 lines
441 B
Mathematica
|
function C = GetConstraints(y, num_constraints, l, u)
|
||
|
% C = GetConstraints(y, num_constraints, l, u)
|
||
|
%
|
||
|
% Get ITML constraint matrix from true labels. See ItmlAlg.m for
|
||
|
% description of the constraint matrix format
|
||
|
|
||
|
m = length(y);
|
||
|
C = zeros(num_constraints, 4);
|
||
|
|
||
|
for (k=1:num_constraints),
|
||
|
i = ceil(rand * m);
|
||
|
j = ceil(rand * m);
|
||
|
if (y(i) == y(j)),
|
||
|
C(k,:) = [i j 1 l];
|
||
|
else
|
||
|
C(k,:) = [i j -1 u];
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|