-
Notifications
You must be signed in to change notification settings - Fork 18
/
fs_unsup_jelsr.m
57 lines (47 loc) · 1.62 KB
/
fs_unsup_jelsr.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
function [W_compute, Y, obj] = fs_unsup_jelsr(data, W_ori, ReducedDim,alpha,beta)
%%%%%%%% Input: data: nSmp*nFea;
%%% W_ori: The original local similarity matrix
%%% ReducedDim: the dimensionality for low dimensionality
%%% embedding $Y$
%%% alpha and beta ar two parameters
[nSmp,nFea] = size(data);
%%%%%%%%%%%%%%%%%%% Normalization of W_ori
D_mhalf = full(sum(W_ori,2).^-.5);
W = compute_W(W_ori,data,D_mhalf);
%%%%%%%%%%%%%%%%%% Eigen_decomposition
Y = compute_Y(data,W, ReducedDim, D_mhalf);
if issparse(data)
data = [data ones(size(data,1),1)];
[nSmp,nFea] = size(data);
else
sampleMean = mean(data);
data = (data - repmat(sampleMean,nSmp,1));
end
%%% To minimize squared loss with L21 normalization
%%%%%%%%%%%% Initialization
AA = data'*data;
Ay = data'*Y;
W_compute = (AA+alpha*eye(nFea))\Ay;
d = sqrt(sum(W_compute.*W_compute,2));
itermax = 20;
obj = zeros(itermax,1);
feaK = data'*data; % modified by liang du
for iter = 1:itermax
%%%%%%%%%%%%%%%%%%% Fix D to updata W_compute, Y
D = 2*spdiags(d,0,nFea,nFea);
%%%%%%%%%%%%%%%% To updata Y
A = (D*feaK+alpha*eye(nFea));
Temp = A\(D*data');
Temp = data*Temp;
Temp = W_ori-beta*eye(nSmp)+beta*Temp;
%%%%% Normalization
Temp = compute_W(Temp,data,D_mhalf);
%%%%% Eigen_decomposition
Y = compute_Y(data,Temp, ReducedDim, D_mhalf);
%%%%%%%%%%%%%%%%% To updata W
B = D*data'*Y;
W_compute = A\B;
%%%%%%%%%%%%%%%%%% Fix W and update D
d = sqrt(sum(W_compute.*W_compute,2));
end
end