|
@@ -1,6 +1,6 @@
|
|
-function [ T , RMSE ] = remnenmf( W , X , G , F , Omega_G, Omega_F, Phi_G, Phi_F , InnerMinIter , InnerMaxIter , Tmax , v, F_theo, delta_measure)
|
|
|
|
|
|
+function [ T , RMSE ] = remnenmf( W , X , G , F , Omega_G, Omega_F, Phi_G, Phi_F , InnerMinIter , InnerMaxIter , Tmax , v, F_theo, delta_measure, nu)
|
|
|
|
|
|
-r = 0;
|
|
|
|
|
|
+r = nu;
|
|
X0 = X;
|
|
X0 = X;
|
|
Omega_G = (Omega_G == 1); % Logical mask is faster than indexing in matlab.
|
|
Omega_G = (Omega_G == 1); % Logical mask is faster than indexing in matlab.
|
|
Omega_F = (Omega_F == 1); % Logical mask is faster than indexing in matlab.
|
|
Omega_F = (Omega_F == 1); % Logical mask is faster than indexing in matlab.
|
|
@@ -13,25 +13,24 @@ em_iter_max = round(Tmax / delta_measure) ;
|
|
T = nan(1,em_iter_max);
|
|
T = nan(1,em_iter_max);
|
|
RMSE = nan(2,em_iter_max);
|
|
RMSE = nan(2,em_iter_max);
|
|
|
|
|
|
-X = G*F+W.*(X0-G*F);
|
|
|
|
-[L,R]=RSI_compression(X,r);
|
|
|
|
-% Compress left and right
|
|
|
|
-X_L = L * X;
|
|
|
|
-X_R = X * R;
|
|
|
|
-G_L = L * G;
|
|
|
|
-F_R = F * R;
|
|
|
|
|
|
+nW = (1-W);
|
|
|
|
+% X = G*F+W.*(X0-G*F);
|
|
|
|
+X = X0 + nW.*(G*F);
|
|
|
|
|
|
-GG = G_L' * G_L;
|
|
|
|
-GX = G_L' * X_L;
|
|
|
|
|
|
+
|
|
|
|
+GG = G' * G;
|
|
|
|
+GX = G' * X ;
|
|
GradF = GG * F - GX;
|
|
GradF = GG * F - GX;
|
|
|
|
|
|
-FF = F_R * F_R';
|
|
|
|
-XF = X_R * F_R';
|
|
|
|
-GradG = G * FF - XF;
|
|
|
|
|
|
+FF = F * F';
|
|
|
|
+XF = X * F' ;
|
|
|
|
+GradG = nOmega_G.*(G * FF - XF);
|
|
|
|
|
|
d = Grad_P([GradG',GradF],[G',F]);
|
|
d = Grad_P([GradG',GradF],[G',F]);
|
|
StoppingCritF = 1.e-3*d;
|
|
StoppingCritF = 1.e-3*d;
|
|
-StoppingCritG = StoppingCritF;
|
|
|
|
|
|
+StoppingCritG = 1.e-3*d;
|
|
|
|
+T_E = [];
|
|
|
|
+T_M = [];
|
|
|
|
|
|
tic
|
|
tic
|
|
i = 1;
|
|
i = 1;
|
|
@@ -40,34 +39,48 @@ RMSE(:,i) = vecnorm(F(:,1:end-1)- F_theo(:,1:end-1),2,2)/sqrt(num_sensor);
|
|
T(i) = toc;
|
|
T(i) = toc;
|
|
while toc<Tmax
|
|
while toc<Tmax
|
|
|
|
|
|
|
|
+ t_e = toc;
|
|
% Estimation step
|
|
% Estimation step
|
|
- X = G*F+W.*(X0-G*F);
|
|
|
|
|
|
+ X = X0 + nW.*(G*F);
|
|
|
|
+% if i>1
|
|
|
|
+% [L,R]=RSI_compression(X,r,L,R);
|
|
|
|
+% else
|
|
|
|
+% [L,R]=RSI_compression(X,r);
|
|
|
|
+% end
|
|
[L,R]=RSI_compression(X,r);
|
|
[L,R]=RSI_compression(X,r);
|
|
% Compress left and right
|
|
% Compress left and right
|
|
X_L = L * X;
|
|
X_L = L * X;
|
|
X_R = X * R;
|
|
X_R = X * R;
|
|
|
|
+ T_E = cat(1,T_E,toc - t_e);
|
|
|
|
|
|
% Maximization step
|
|
% Maximization step
|
|
for j =1:v
|
|
for j =1:v
|
|
- F_R = F * R;
|
|
|
|
- FF = F_R * F_R';
|
|
|
|
- XF = X_R * F_R' - Phi_G * FF;
|
|
|
|
-
|
|
|
|
- G(Omega_G) = 0; % Convert G to \Delta G
|
|
|
|
- [ G , iterG ] = MaJ_G_EM_NeNMF( FF , XF , G , InnerMinIter , InnerMaxIter , StoppingCritG , nOmega_G); % Update \Delta G
|
|
|
|
- G(Omega_G) = Phi_G(Omega_G); % Convert \Delta G to G
|
|
|
|
|
|
+
|
|
|
|
+ t_m = toc;
|
|
|
|
+% F_R = F * R;
|
|
|
|
+% FF = F_R * F_R';
|
|
|
|
+ FF = F * F';
|
|
|
|
+ XF = X_R * (F * R)' - Phi_G * FF;
|
|
|
|
+
|
|
|
|
+% G(Omega_G) = 0; % Convert G to \Delta G
|
|
|
|
+ [ GradG , iterG ] = MaJ_G_EM_NeNMF( FF , XF , GradG , InnerMinIter , InnerMaxIter , StoppingCritG , nOmega_G); % Update \Delta G
|
|
|
|
+% G(Omega_G) = Phi_G(Omega_G); % Convert \Delta G to G
|
|
|
|
+ G = GradG + Phi_G;
|
|
niter = niter + iterG;
|
|
niter = niter + iterG;
|
|
if(iterG<=InnerMinIter)
|
|
if(iterG<=InnerMinIter)
|
|
StoppingCritG = 1.e-1*StoppingCritG;
|
|
StoppingCritG = 1.e-1*StoppingCritG;
|
|
end
|
|
end
|
|
|
|
|
|
- G_L = L * G;
|
|
|
|
- GG = G_L' * G_L;
|
|
|
|
- GX = G_L' * X_L - GG * Phi_F;
|
|
|
|
|
|
+% G_L = L * G;
|
|
|
|
+% GG = G_L' * G_L;
|
|
|
|
+ GG = G' * G;
|
|
|
|
+ GX = (L * G)' * X_L - GG * Phi_F;
|
|
|
|
|
|
F(Omega_F) = 0; % Convert F to \Delta F
|
|
F(Omega_F) = 0; % Convert F to \Delta F
|
|
|
|
+% F = F - Phi_F;
|
|
[ F , iterF ] = MaJ_F_EM_NeNMF( GG , GX , F , InnerMinIter , InnerMaxIter , StoppingCritF , nOmega_F); % Update \Delta F
|
|
[ F , iterF ] = MaJ_F_EM_NeNMF( GG , GX , F , InnerMinIter , InnerMaxIter , StoppingCritF , nOmega_F); % Update \Delta F
|
|
F(Omega_F) = Phi_F(Omega_F); % Convert \Delta F to F
|
|
F(Omega_F) = Phi_F(Omega_F); % Convert \Delta F to F
|
|
|
|
+% F = F + Phi_F;
|
|
niter = niter + iterF;
|
|
niter = niter + iterF;
|
|
if(iterF<=InnerMinIter)
|
|
if(iterF<=InnerMinIter)
|
|
StoppingCritF = 1.e-1*StoppingCritF;
|
|
StoppingCritF = 1.e-1*StoppingCritF;
|
|
@@ -81,13 +94,17 @@ while toc<Tmax
|
|
T(i) = toc;
|
|
T(i) = toc;
|
|
RMSE(:,i) = vecnorm(F(:,1:end-1) - F_theo(:,1:end-1),2,2)/sqrt(num_sensor);
|
|
RMSE(:,i) = vecnorm(F(:,1:end-1) - F_theo(:,1:end-1),2,2)/sqrt(num_sensor);
|
|
end
|
|
end
|
|
|
|
+ T_M = cat(1,T_M,toc - t_m);
|
|
|
|
+
|
|
end
|
|
end
|
|
|
|
|
|
end
|
|
end
|
|
niter
|
|
niter
|
|
|
|
+disp(['rem E step : ',num2str(median(T_E))])
|
|
|
|
+disp(['rem M step : ',num2str(median(T_M))])
|
|
end
|
|
end
|
|
|
|
|
|
-function [ L,R ] = RSI_compression(X,r)
|
|
|
|
|
|
+function [ L,R ] = RSI_compression(X,r,varargin)
|
|
% Tepper, M., & Sapiro, G. (2016). Compressed nonnegative
|
|
% Tepper, M., & Sapiro, G. (2016). Compressed nonnegative
|
|
% matrix factorization is fast and accurate. IEEE Transactions
|
|
% matrix factorization is fast and accurate. IEEE Transactions
|
|
% on Signal Processing, 64(9), 2269-2283.
|
|
% on Signal Processing, 64(9), 2269-2283.
|
|
@@ -97,16 +114,25 @@ function [ L,R ] = RSI_compression(X,r)
|
|
% Date: 13/04/2018
|
|
% Date: 13/04/2018
|
|
%
|
|
%
|
|
|
|
|
|
-compressionLevel=20;
|
|
|
|
|
|
+compressionLevel=2;
|
|
[m,n]=size(X);
|
|
[m,n]=size(X);
|
|
|
|
|
|
-l = min(n, max(compressionLevel, r + 10));
|
|
|
|
-
|
|
|
|
-OmegaL = randn(n,l);
|
|
|
|
|
|
+l = min(min(n,m), max(compressionLevel, r ));
|
|
|
|
+
|
|
|
|
+switch nargin
|
|
|
|
+ case 2
|
|
|
|
+ OmegaL = randn(n,l);
|
|
|
|
+ OmegaR = randn(l, m);
|
|
|
|
+ q = 4;
|
|
|
|
+ case 4
|
|
|
|
+ OmegaL = varargin{2};
|
|
|
|
+ OmegaR = varargin{1};
|
|
|
|
+ q = 1;
|
|
|
|
+end
|
|
|
|
|
|
Y = X * OmegaL;
|
|
Y = X * OmegaL;
|
|
|
|
|
|
-for i=1:4
|
|
|
|
|
|
+for i=1:q
|
|
|
|
|
|
[Y,~]=qr(Y,0);
|
|
[Y,~]=qr(Y,0);
|
|
S=X'*Y;
|
|
S=X'*Y;
|
|
@@ -116,10 +142,10 @@ end
|
|
[L,~]=qr(Y,0);
|
|
[L,~]=qr(Y,0);
|
|
L=L';
|
|
L=L';
|
|
|
|
|
|
-OmegaR = randn(l, m);
|
|
|
|
|
|
+
|
|
Y = OmegaR * X;
|
|
Y = OmegaR * X;
|
|
|
|
|
|
-for i=1:4
|
|
|
|
|
|
+for i=1:q
|
|
[Y,~]=qr(Y',0);
|
|
[Y,~]=qr(Y',0);
|
|
S=X*Y;
|
|
S=X*Y;
|
|
[Z,~]=qr(S,0);
|
|
[Z,~]=qr(S,0);
|