-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtensor2.m
47 lines (36 loc) · 956 Bytes
/
tensor2.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
%%%% Y the input tensor data with dropout, W is the set, in W, the data of Y can be observed.
T=Y.*W;
%R is the cp rank,beta and inf_L are paremeters
inf_L=3;
R;
beta;
eps=1e-5;
L=cell(1,inf_L);
Xold=tensor(zeros(T.size));
for j=1:100
for i=1:inf_L
P=cp_nmu(T+(1-W).*Xold,R);
L{i}=P;
end
Plambda=zeros(1,inf_L);
for i=1:inf_L
Nuclearnorm_P=sum(abs(L{i}.lambda));
Plambda(i)=Nuclearnorm_P;
end
[value,index]=min(Plambda);
P_need=L{index};
P_new_lambda=max(P_need.lambda-beta,0);
P_new_U=P_need.U;
P_new=ktensor(P_new_lambda,P_new_U);
Xnew=P_new; Xnew=tensor( Xnew);
Fold=(1/2)*(norm(T-(1-W).*Xold))^2+beta*value;
Fnew=(1/2)*(norm(T-(1-W).*Xnew))^2+beta*value;
if(abs(Fnew-Fold)/Fold<eps)
Xopt=Xnew;
break;
end
Xold=Xnew;
end
Xopt=Xnew;
%%%%% output: the imputed thnsor
Xneed=(T+(1-W).*Xopt);