From 556f7880a6ed26574557f7bf90496056dcbdc896 Mon Sep 17 00:00:00 2001 From: Luo Pei Date: Thu, 14 Mar 2013 16:49:06 +0800 Subject: [PATCH] add debug --- multi_lrr_acc.m | 53 +++++++++++++++++++++++++++++++++++++-- toolbox_graph/plot_mesh.m | 6 ++--- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/multi_lrr_acc.m b/multi_lrr_acc.m index 13da841..f235e27 100644 --- a/multi_lrr_acc.m +++ b/multi_lrr_acc.m @@ -58,7 +58,9 @@ mu=1e-6; max_mu=10^10; rho=1.9; -epsilon=1e-4; +% epsilon=1e-4; +% epsilon2=1e-5; % must be small! +epsilon=1e-6; epsilon2=1e-5; % must be small! % pre caculate matrix value @@ -96,7 +98,7 @@ M=cell(k,1); -MAX_ITER=2000; +MAX_ITER=1000; iter=0; convergenced=false; @@ -108,6 +110,7 @@ while ~convergenced if iter>MAX_ITER fprintf(1,'max iter num reached!\n'); + save_matrix(J,S,Z,F); break; end cmu=cell(k,1); @@ -131,6 +134,10 @@ Zk{i}=Z{i}; Z{i}=reshape(ZZ(i,:),n,n)'; end + + % TODO: for debug + % print_matrix(J,S,Z,F,svp,mu); + % update E_i Ek=E; [E]=cellfun(@updateE,X,S,Y,cmu,clambda,'UniformOutput',false); @@ -164,6 +171,7 @@ fprintf(1,'svp%d %d,',i,svp{i}); end fprintf(1,'\n'); + save_matrix(J,S,Z,F); end % update multipliers [Y]=cellfun(@updateY,Y,cmu,Xc,'UniformOutput',false); @@ -245,3 +253,44 @@ warning(S.identifier, S.message); result = NaN; +function [] = save_matrix(J,S,Z,F) + k=length(J); + % TODO: for debug + for i=1:k + h=figure('Visible', 'off'); + imagesc(S{i}); + colormap(gray); + axis equal; + saveas(h,['S' num2str(i) '.png']); + end + for i=1:k + h=figure('Visible', 'off'); + imagesc(Z{i}); + colormap(gray); + axis equal; + saveas(h,['Z' num2str(i) '.png']); + end + for i=1:k + h=figure('Visible', 'off'); + imagesc(J{i}); + colormap(gray); + axis equal; + saveas(h,['J' num2str(i) '.png']); + end + for i=1:k + h=figure('Visible', 'off'); + imagesc(F{i}); + colormap(gray); + axis equal; + saveas(h,['F' num2str(i) '.png']); + end + +function [] = print_matrix(J,S,Z,F,svp,mu) + % TODO: for debug + k=length(J); + for i=1:k + [aa bb1 cc]=svd(Z{i}); + [aa bb2 cc]=svd(S{i}); + [aa bb3 cc]=svd(F{i}); + fprintf(1,'Z%d rank %d,S%d rank %d,F%d rank %d,J%d rank is %d\n',i,length(find(diag(bb1)>1/mu)),i,length(find(diag(bb2)>1/mu)),i,length(find(diag(bb3)>1/mu)),i,svp{i}); + end diff --git a/toolbox_graph/plot_mesh.m b/toolbox_graph/plot_mesh.m index 941104d..b29ab77 100644 --- a/toolbox_graph/plot_mesh.m +++ b/toolbox_graph/plot_mesh.m @@ -125,9 +125,9 @@ h = patch('vertices',vertex,'faces',face,'FaceVertexCData',face_vertex_color, 'FaceColor',shading_type); end colormap gray(256); -lighting phong; -camlight infinite; -camproj('perspective'); +% lighting phong; +% camlight infinite; +% camproj('perspective'); axis square; axis off;