Skip to content

Commit

Permalink
Fixed IALM with LMSVDS
Browse files Browse the repository at this point in the history
IALM with LMSVDS crashed with bigger videos
  • Loading branch information
andrewssobral committed Jul 29, 2022
1 parent e4e8a60 commit 46c1575
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 54 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![View LRSLibrary on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/48404-lrslibrary)

Last Page Update: **07/03/2020**
Last Page Update: **29/07/2022**, Previous Page Update: **07/03/2020**

Latest Library Version: **1.0.10** (see Release Notes for more info)
Latest Library Version: **1.0.11** (see Release Notes for more info)

LRSLibrary
----------
Expand Down Expand Up @@ -444,6 +444,8 @@ If you have any problems or questions, please contact the author: Andrews Sobral

Release Notes:
--------------
* Version 1.0.11: Fixed IALM with LMSVDS (Liu et al. 2012).

* Version 1.0.10: Added ReProCS (Narayanamurthy and Vaswani, 2017a) and MEDRoP (Narayanamurthy and Vaswani, 2017b). Thanks to Praneeth Narayanamurthy.

* Version 1.0.9: Fixed some issues for matrix completion methods.
Expand Down
5 changes: 2 additions & 3 deletions algorithms/rpca/IALM_LMSVDS/inexact_alm_rpca_with_lmsvds.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
iter = 0;
total_svd = 0;
converged = false;
stopCriterion = 1;
sv = 10;
while ~converged
iter = iter + 1;
Expand All @@ -73,8 +72,8 @@
E_hat = E_hat+min(temp_T + lambda/mu, 0);

myA = D - E_hat + (1/mu)*Y;
[myM,myN] = size(myA);
myR = 2*myM/100;
[myM, ~] = size(myA);
myR = (myM/100)/2;
[U,S,V] = LMSVDS(myA, myR, []);

diagS = diag(S);
Expand Down
Binary file modified gui/main_about.fig
Binary file not shown.
94 changes: 45 additions & 49 deletions libs/SVD/LMSVDS.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,46 @@
% end

r = uint8(r);
% disp(['r=', num2str(r)])

% set parameters
mainargin = nargin;
set_param;
tol = 1e-8;
maxit = 300;
idisp = 0;
mn = min(m,n);

if r <= mn*0.02
memo = 5;
elseif r <= mn*0.03
memo = 4;
else
memo = 3;
end

if r >= mn*0.015 && r <= mn*0.035
sub = 1;
else
sub = 2;
end

if isfield(opts, 'gvk'); tau = opts.gvk; else tau = 10; end
% working size
k = min([2*r,r+tau,m,n]);
% initial guess
% disp(n)
% disp(['k=', num2str(k)])
% Y = randn(n,k);
Y = randn(n,round(k));

if mainargin < 3; return; end

if isfield(opts, 'tol'); tol = opts.tol; end
if isfield(opts,'maxit'); maxit = opts.maxit; end
if isfield(opts, 'memo'); memo = opts.memo; end
if isfield(opts,'idisp'); idisp = opts.idisp; end
if isfield(opts,'initY'); Y = opts.initY(:,1:k); end
if isfield(opts, 'sub'); sub = opts.sub; end

% initialize
if isnumeric(A)
Expand Down Expand Up @@ -80,55 +116,15 @@


%% %%%%%%% nested functions %%%%%%% %%
function set_param

tol = 1e-8;
maxit = 300;
idisp = 0;
mn = min(m,n);

if r <= mn*0.02;
memo = 5;
elseif r <= mn*0.03;
memo = 4;
else
memo = 3;
end

if r >= mn*0.015 & r <= mn*0.035
sub = 1;
else
sub = 2;
end

if isfield(opts, 'gvk'); tau = opts.gvk; else tau = 10; end
% working size
k = min([2*r,r+tau,m,n]);
% initial guess
%disp(n)
%disp(k)
%Y = randn(n,k);
Y = randn(n,round(k));

if mainargin < 3; return; end

if isfield(opts, 'tol'); tol = opts.tol; end
if isfield(opts,'maxit'); maxit = opts.maxit; end
if isfield(opts, 'memo'); memo = opts.memo; end
if isfield(opts,'idisp'); idisp = opts.idisp; end
if isfield(opts,'initY'); Y = opts.initY(:,1:k); end
if isfield(opts, 'sub'); sub = opts.sub; end

end % set_param

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [U,S,V] = get_svd(X,Y)
method = 2;
switch method
case 1;
case 1
[V,S,W] = svd(Y,0);
U = X*W;
case 2;
case 2
[V,R] = qr(Y,0);
[W,S,Z] = svd(R');
U = X*W; V = V*Z;
Expand Down Expand Up @@ -187,7 +183,6 @@
Ym(:,k+1:2*k) = Y;
Lm = k;


rvr = zeros(r,1);
chg_rvr = 1;
chgv = zeros(maxit,1);
Expand Down Expand Up @@ -261,7 +256,7 @@
%portion = csum/csum(end);
%L = find(portion > .999,1)
L = sum(sdT > 5e-8,1);
if L < .95*Lm; %disp([L Lm])
if L < .95*Lm %disp([L Lm])
Lm = L;
Icut = idx(1:Lm);
Py = Py(:,Icut);
Expand Down Expand Up @@ -326,6 +321,7 @@
n = size(Y,1);
mn = min(m,n);
k = size(Y,2);
% disp(['k=', num2str(k), ' : r=', num2str(r)])
if k < r; error('working size too small'); end

if memo > 0
Expand All @@ -337,13 +333,13 @@
else
Lm = 0;
end
%disp(r)
%rvr = zeros(r,1);
% disp(r)
% rvr = zeros(r,1);
rvr = zeros(round(r),1);
chg_rvr = 1;
chgv = zeros(maxit,1);
xtrm = zeros(maxit,1);
%hrvs = zeros(maxit,r);
% hrvs = zeros(maxit,r);
hrvs = zeros(maxit,round(r));
kktc = zeros(maxit,1);
disp_str = 'iter %3i: memo used %i, chg_rvr %8.4e\n';
Expand Down Expand Up @@ -413,7 +409,7 @@
dT = diag(T);
[sdT,idx] = sort(dT,'descend');
L = sum(sdT > 5e-10,1);
if L < .95*Lm; %disp([L Lm])
if L < .95*Lm %disp([L Lm])
Lm = L;
Icut = idx(1:Lm);
Px = Px(:,Icut);
Expand Down

0 comments on commit 46c1575

Please sign in to comment.