-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLM3FE.m
111 lines (97 loc) · 4.7 KB
/
LM3FE.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
function [matUs_opt, theta_opt, matW_opt] = LM3FE(singleTrainFeaL, trainLabelsL, set, para, option)
% -------------------------------------------------------------------------
% Implementation of the large margin multi-view multi-task feature extraction
% -------------------------------------------------------------------------
% -----------------------------------------------------------
% Pre-calculate ||x_n||_inf
% -----------------------------------------------------------
trainFeaL = [];
for v = 1:set.nbV
trainFeaL = [trainFeaL singleTrainFeaL{v}];
end
trainFeaL_inf = max(abs(trainFeaL), [], 2); clear trainFeaL
% -----------------------------------------------------------
% Initialization of the multi-view combination coefficients
% -----------------------------------------------------------
if option.selfDefinedTheta || option.uniformTheta
theta = para.theta;
else
theta = (1.0 / set.nbV) * ones(set.nbV, 1);
end
% -----------------------------------------------------------
% Initialization of the feature selection matrices
% -----------------------------------------------------------
matUs = cell(set.nbV, 1);
for v = 1:set.nbV
rand('seed', v);
matUs{v} = rand(set.feaDim(v), set.nbP);
end
% -----------------------------------------------------------
% Initialization of the classification matrix
% -----------------------------------------------------------
matW0 = zeros(set.nbP, set.nbP); vecB0 = zeros(1,set.nbP);
[matW, vecB, obj_W] = optimizeW(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matUs, theta, matW0, vecB0, set, para);
obj = computeObjPreW(obj_W, matUs, theta, set, para);
% obj_temp1 = computeObj(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW, vecB, matUs, theta, set, para);
obj_ini = obj;
% -------------------------------------------------------------------------
% Solve the optimization problem in an alternative procedure
% -------------------------------------------------------------------------
loop = 1; iter = 0;
while loop
iter = iter + 1;
% -----------------------------------------------------------
% Optimize each U{v}
% -----------------------------------------------------------
% matUs_new = matUs;
matUs_new = optimizeUs(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW, vecB, theta, matUs, set, para, option);
% obj_temp2 = computeObj(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW, vecB, matUs_new, theta, set, para);
clear matUs
% -----------------------------------------------------------
% Optimize theta if needed
% -----------------------------------------------------------
if option.selfDefinedTheta == 0 && option.uniformTheta == 0
% theta_new = optimizeThetaPGM(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW, vecB, matUs_new, theta, set, para);
% theta_new = optimizeThetaOGM(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW, vecB, matUs_new, theta, set, para);
theta_new = optimizeTheta(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW, vecB, matUs_new, theta, set, para);
else
theta_new = theta;
end
clear matZs
% obj_temp3 = computeObj(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW, vecB, matUs_new, theta_new, set, para);
% -----------------------------------------------------------
% Optimize the expansion coefficents
% -----------------------------------------------------------
[matW_new, vecB_new, obj_W_new] = ...
optimizeW(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matUs_new, theta_new, matW, vecB, set, para);
% obj_temp4 = computeObj(singleTrainFeaL, trainLabelsL, trainFeaL_inf, matW_new, vecB_new, matUs_new, theta_new, set, para);
% -----------------------------------------------------------
% Compute the objective value
% -----------------------------------------------------------
obj_new = computeObjPreW(obj_W_new, matUs_new, theta_new, set, para);
% -----------------------------------------------------------
% Check the convergence
% -----------------------------------------------------------
loop = checkConvergence(obj_new, obj, obj_ini, theta_new, theta, iter, set, para, option);
% -----------------------------------------------------------
% Update the variables
% -----------------------------------------------------------
if loop
matUs = cell(set.nbV, 1);
for v = 1:set.nbV
matUs{v} = matUs_new{v};
end
theta = theta_new;
matW = matW_new;
vecB = vecB_new;
obj = obj_new;
clear matUs_new theta_new matW_new vecB_new obj_new
end
end
matUs_opt = cell(set.nbV, 1);
for v = 1:set.nbV
matUs_opt{v} = matUs_new{v};
end
theta_opt = theta_new;
matW_opt = matW_new;
end