├── README.md └── gitlocal ├── .gitattributes ├── LRR ├── demo.m ├── dictlearn.m ├── exact_alm_lrr_l1v2.m ├── exact_alm_lrr_l21v2.m ├── inexact_alm_lrr_l1.m ├── inexact_alm_lrr_l21.m ├── solve_l1l2.m └── solve_lrr.m ├── NLRRSS ├── NLRR.m ├── NLRR.m~ ├── NLRRE.m ├── NLRRplus.m ├── NLRRplus.m~ └── NLRRplusE.m ├── OLRSC ├── OLRR_solve_D.m ├── OLRR_solve_main.m └── OLRR_solve_ve.m ├── ORPCA ├── ORPCA_new.m ├── ORPCA_new.m~ ├── solve_proj2.m ├── stoc_rpca.m └── update_col_orpca.m ├── README.md ├── Result ├── Protein_mul │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ ├── orpca.mat │ └── ssc.mat ├── Protein_sin │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ └── orpca.mat ├── imagenet_mul │ ├── lrr1_214.mat │ ├── lrr1_327.mat │ ├── lrr1_62.mat │ ├── lrr2_214.mat │ ├── nlrr1_214.mat │ ├── nlrr1_327.mat │ ├── nlrr1_62.mat │ ├── nlrr2_214.mat │ ├── nlrrp1_214.mat │ ├── nlrrp1_327.mat │ ├── nlrrp1_62.mat │ ├── nlrrp2_214.mat │ ├── olrsc1_214.mat │ ├── olrsc1_327.mat │ ├── olrsc1_62.mat │ ├── orpca1_214.mat │ ├── orpca1_327.mat │ └── orpca1_62.mat ├── imagenet_sin │ ├── lrr1_214.mat │ ├── lrr2_214.mat │ ├── nlrr1_214.mat │ ├── nlrr2_214.mat │ ├── nlrrp1_214.mat │ ├── nlrrp2_214.mat │ ├── olrsc1_214.mat │ ├── olrsc2_214.mat │ ├── orpca1_214.mat │ └── orpca2_214.mat ├── mnist_conv │ ├── nlrr.mat │ └── nlrrp.mat ├── mnist_mul │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ ├── orpca.mat │ └── ssc.mat ├── mnist_sin │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ └── orpca.mat ├── protein_conv │ ├── nlrr.mat │ └── nlrrp.mat ├── simulation_sin │ ├── 2800lrr.mat │ ├── 2800nlrr.mat │ ├── 2800nlrrp.mat │ ├── 2800olrsc.mat │ ├── 2800orpca.mat │ ├── 3200lrr.mat │ ├── 3200nlrr.mat │ ├── 3200nlrrp.mat │ ├── 3200olrsc.mat │ ├── 3200orpca.mat │ ├── 3600lrr.mat │ ├── 3600nlrr.mat │ ├── 3600nlrrp.mat │ ├── 3600olrsc.mat │ ├── 3600orpca.mat │ ├── 4000lrr.mat │ ├── 4000nlrr.mat │ ├── 4000nlrrp.mat │ ├── 4000olrsc.mat │ ├── 4000orpca.mat │ ├── 40lrr.mat │ ├── 40nlrr.mat │ ├── 40nlrrp.mat │ ├── 40olrsc.mat │ ├── 40orpca.mat │ ├── 4400nlrr.mat │ ├── 4400nlrrp.mat │ ├── 45lrr.mat │ ├── 45nlrr.mat │ ├── 45nlrrp.mat │ ├── 45olrsc.mat │ ├── 45orpca.mat │ ├── 50lrr.mat │ ├── 50nlrr.mat │ ├── 50nlrrp.mat │ ├── 50olrsc.mat │ ├── 50orpca.mat │ ├── 55lrr.mat │ ├── 55nlrr.mat │ ├── 55nlrrp.mat │ ├── 55olrsc.mat │ ├── 55orpca.mat │ ├── 60lrr.mat │ ├── 60nlrr.mat │ ├── 60nlrrp.mat │ ├── 60olrsc.mat │ ├── 60orpca.mat │ ├── 65lrr.mat │ ├── 65nlrr.mat │ ├── 65nlrrp.mat │ ├── 65olrsc.mat │ ├── 65orpca.mat │ ├── 70lrr.mat │ ├── 70nlrr.mat │ ├── 70nlrrp.mat │ ├── 70olrsc.mat │ ├── 70orpca.mat │ ├── 75lrr.mat │ ├── 75nlrr.mat │ ├── 75nlrrp.mat │ ├── 75olrsc.mat │ ├── 75orpca.mat │ ├── 80lrr.mat │ ├── 80nlrr.mat │ ├── 80nlrrp.mat │ ├── 80olrsc.mat │ ├── 80orpca.mat │ ├── 85lrr.mat │ ├── 85nlrr.mat │ ├── 85nlrrp.mat │ ├── 85olrsc.mat │ ├── 85orpca.mat │ ├── 90lrr.mat │ ├── 90nlrr.mat │ ├── 90nlrrp.mat │ ├── 90olrsc.mat │ └── 90orpca.mat ├── svhn_conv │ ├── nlrr.mat │ └── nlrrp.mat ├── svhn_mul │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ └── orpca.mat ├── svhn_sin │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ └── orpca.mat ├── usps_mul │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ ├── orpca.mat │ └── ssc.mat └── usps_sin │ ├── lrr.mat │ ├── nlrr.mat │ ├── nlrrp.mat │ ├── olrsc.mat │ ├── orpca.mat │ └── ssc.mat ├── SSC ├── BuildAdjacency.m ├── DataProjection.m ├── Hungarian.m ├── Misclassification.m ├── SSC.m ├── SpectralClustering.m ├── admmLasso_mat_func.m ├── admmOutlier_mat_func.m ├── computeLambda_mat.m ├── errorCoef.m ├── errorLinSys.m ├── matrixNormalize.m ├── missclassGroups.m ├── readme.pdf ├── readme.rtf ├── run_SSC_Faces.m ├── run_SSC_MS.m └── thrC.m ├── SVHN.mat ├── clusterings ├── F.m ├── NMI.m ├── bestMap.m ├── calnk.m ├── calnumber.m ├── clustering.m ├── f_P.m ├── hungarian.m ├── matlab.mat ├── nmipp.m ├── principlecoms.m └── spectralclustering.m ├── imagenet100data.mat ├── imagenet100label.mat ├── mnistdata.mat ├── mnistlabel.mat ├── protein.mat ├── sytheticdata.m ├── test_Imagenet.m ├── test_Mnist.m ├── test_Protein.m ├── test_SVHN.m ├── test_Usps.m ├── testall.m ├── testsimulation.m ├── usps.mat └── wholeline.m /README.md: -------------------------------------------------------------------------------- 1 | # subspace-clustering in the '/gitlocal' folder 2 | 3 | Experimental code for comparing our new algorithm for subspace clustering---'NLRR++' with other existing methods. 4 | 5 | 1. Subspace clustering methods are organized in folders '~/ORPCA, ~/OLRSC, ~/LRR, ~/SSC, ~/NLRRSS' 6 | 7 | 2. NLRR ('NLRR.m', 'NLRRE.m') and NLRR++ ('NLRRplus.m', 'NLRRplusE.m') functions are displayed in the folder'~/NLRRSS'. 8 | 9 | 3. Code for running experiments are named as 'test**.m' which can be executed directly. 10 | 11 | 4. Datasets: 'Imagenet'(features trained by CNN), 'MNIST', 'SVHN', 'USPS', 'Protein'. 12 | 13 | 5. Clustering baseline and evaluation metric function are in the '~/clusterings' folder. 14 | 15 | 6. Competing methods: 16 | 17 | (1) NLRR:Jie Shen and Ping Li. 2016. Learning structured low-rank representation via matrix factorization. In Proceedings of the 19th International Conference on Arti€cial Intelligence and Statistics (ICAIS). 500–509 18 | 19 | (2) OLRSC:Jie Shen, Ping Li, and Huan Xu. 2016. Online Low-Rank Subspace Clustering by 20 | Basis Dictionary Pursuit. In Proceedings of the 33rd International Conference on Machine Learning (ICML). 622–631 21 | 22 | (3) LRR: Guangcan Liu, Zhouchen Lin, and Yong Yu. 2010. Robust subspace segmentation by low-rank representation. In Proceedings of the 27th international conference on machine learning (ICML). 663–670. 23 | 24 | (4) SSC:Ehsan Elhamifar and Rene Vidal. 2013. Sparse subspace clustering: Algorithm, theory, and applications. IEEE transactions on paˆern analysis and machine intelligence 35, 11 (2013), 2765–2781. 25 | 26 | (5) ORPCA:Jiashi Feng, Huan Xu, and Shuicheng Yan. 2013. Online robust pca via stochastic optimization. In Advances in Neural Information Processing Systems. 404–412 27 | -------------------------------------------------------------------------------- /gitlocal/.gitattributes: -------------------------------------------------------------------------------- 1 | *.mat filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /gitlocal/LRR/demo.m: -------------------------------------------------------------------------------- 1 | function [] = demo() 2 | A = randn(100,200); 3 | X = randn(100,100); 4 | lambda = 0.01; 5 | 6 | disp('solve min |Z|_* + lambda |E|_21 s.t. X = AZ + E by exact ALM ...'); 7 | 8 | tic; 9 | [Z1,E1] = solve_lrr(X,A,lambda,0,0); 10 | obj1 = sum(svd(Z1)) + lambda*sum(sqrt(sum(E1.^2,1))); 11 | toc; 12 | 13 | disp(['objective value=' num2str(obj1)]); 14 | 15 | disp('solve min |Z|_* + lambda |E|_21 s.t. X = AZ + E by inexact ALM ...'); 16 | 17 | tic; 18 | [Z2,E2] = solve_lrr(X,A,lambda,0,1); 19 | obj2 = sum(svd(Z2)) + lambda*sum(sqrt(sum(E2.^2,1))); 20 | toc; 21 | disp(['objective value=' num2str(obj2)]); 22 | 23 | diff = max(max(abs(Z1 - Z2))); 24 | 25 | warning(['difference of the solution found by those two approaches: |Z1 - Z2|_inf=' num2str(diff)]); 26 | 27 | disp('solve min |Z|_* + lambda |E|_1 s.t. X = AZ + E by exact ALM ...'); 28 | tic; 29 | [Z1,E1] = solve_lrr(X,A,lambda,1,0); 30 | obj1 = sum(svd(Z1)) + lambda*sum(sqrt(sum(E1.^2,1))); 31 | toc; 32 | 33 | disp(['objective value=' num2str(obj1)]); 34 | 35 | disp('solve min |Z|_* + lambda |E|_1 s.t. X = AZ + E by inexact ALM ...'); 36 | tic; 37 | [Z2,E2] = solve_lrr(X,A,lambda,1,1); 38 | obj2 = sum(svd(Z2)) + lambda*sum(sqrt(sum(E2.^2,1))); 39 | toc; 40 | disp(['objective value=' num2str(obj2)]); 41 | 42 | diff = max(max(abs(Z1 - Z2))); 43 | 44 | warning(['difference of the solution found by those two approaches: |Z1 - Z2|_inf=' num2str(diff) ]); 45 | -------------------------------------------------------------------------------- /gitlocal/LRR/dictlearn.m: -------------------------------------------------------------------------------- 1 | function [A_hat] = dictlearn(D,lambda) 2 | %Aug 2013 3 | %%% This function is to find the dictionary matrix A for LRR 4 | %%% min_{A,Z,E} |Z|_* + \lambda |E|_1 s.t. D = AZ + E 5 | %%% 6 | 7 | %%% input: 8 | % D -- M by N data matrix, each column is a data point 9 | 10 | %%% outputs: 11 | % A_hat -- estimation of the dicitonary matrix A 12 | %%% parameters: 13 | % lambda -- the key parameter lambda 14 | % default: 1 /sqrt(max(m,n)) 15 | 16 | warning off all; 17 | addpath lrr; 18 | [m,n] = size(D); 19 | eps = 1e-3; 20 | 21 | if nargin < 2 || isempty(lambda) 22 | lambda = 1/sqrt(max(m,n)); 23 | end 24 | 25 | %disp('run rpca ...'); 26 | D_hat = inexact_alm_rpca(D,lambda); 27 | %disp('construct dictionary ...') 28 | [U,S,V] = svd(D_hat,'econ'); 29 | S = diag(S); 30 | r = sum(S>eps*S(1)); 31 | V = V(:,1:r); 32 | U = U(:,1:r); 33 | S = S(1:r); 34 | 35 | D_hat = U*diag(S)*V'; 36 | A_hat = normc(D_hat); 37 | 38 | %disp('dictionary learning done.') 39 | end 40 | -------------------------------------------------------------------------------- /gitlocal/LRR/exact_alm_lrr_l1v2.m: -------------------------------------------------------------------------------- 1 | function [Z_hat, E_hat] = exact_alm_lrr_l1v2(D, A, lambda, tol, maxIter,display) 2 | 3 | % Aug 2013 4 | % This matlab code implements the Exact ALM algorithm for 5 | % min_{Z,E} |Z|_* + lambda |E|_1 s.t. D = AZ + E 6 | % 7 | % D - m x n matrix of observations/data (required input) 8 | % A - m x k matrix of the dictionary (required input) 9 | 10 | % lambda - weight on sparse error term in the cost function 11 | % 12 | % tol - tolerance for stopping criterion. 13 | % - DEFAULT 1e-7 if omitted or -1. 14 | % 15 | % maxIter - maximum number of iterations 16 | % - DEFAULT 1000, if omitted or -1. 17 | % 18 | [m n] = size(D); 19 | k = size(A,2); 20 | n_max = max(m,n); 21 | 22 | 23 | if nargin < 3 || isempty(lambda) 24 | lambda = 1 / sqrt(n_max); 25 | end 26 | 27 | if nargin < 4 || isempty(tol) 28 | tol = 1e-7; 29 | end 30 | 31 | if nargin < 5 || isempty(maxIter) 32 | maxIter = 1000; 33 | end 34 | 35 | if nargin<6 || isempty(display) 36 | display = false; 37 | end 38 | 39 | maxIter_primal = 10000; 40 | % initialize 41 | Y = sign(D); 42 | norm_two = norm(Y,2); 43 | norm_inf = norm( Y(:), inf) / lambda; 44 | dual_norm = max(norm_two, norm_inf); 45 | Y = Y / dual_norm; 46 | 47 | W = zeros(k,n); 48 | 49 | Z_hat = zeros(k,n); 50 | E_hat = zeros(m,n); 51 | %parameters 52 | dnorm = norm(D, 'fro'); 53 | tolProj1 = 1e-6 * dnorm; 54 | 55 | anorm = norm(A,2); 56 | tolProj2 = 1e-6 * dnorm/anorm; 57 | 58 | mu = .5/norm_two; % this one can be tuned 59 | rho = 6; % this one can be tuned 60 | 61 | %pre-computation 62 | if m>=k 63 | inv_ata = inv(eye(k) + A'*A); 64 | else 65 | inv_ata = eye(k) - A'/(eye(m)+A*A')*A; 66 | end 67 | 68 | iter = 0; 69 | while iter < maxIter 70 | iter = iter + 1; 71 | 72 | % solve the primal problem by alternative projection 73 | primal_iter = 0; 74 | 75 | while primal_iter < maxIter_primal 76 | primal_iter = primal_iter + 1; 77 | temp_Z = Z_hat; 78 | temp_E = E_hat; 79 | 80 | %update J 81 | temp = temp_Z + W/mu; 82 | [U S V] = svd(temp, 'econ'); 83 | 84 | diagS = diag(S); 85 | svp = length(find(diagS > 1/mu)); 86 | diagS = max(0,diagS - 1/mu); 87 | 88 | if svp < 0.5 %svp = 0 89 | svp = 1; 90 | end 91 | J_hat = U(:,1:svp)*diag(diagS(1:svp))*V(:,1:svp)'; 92 | 93 | % update Z 94 | temp = J_hat + A'*(D - temp_E) + (A'*Y-W)/mu; 95 | Z_hat = inv_ata*temp; 96 | 97 | %update E 98 | temp = D - A*Z_hat + Y/mu; 99 | E_hat = max(0,temp - lambda/mu) + min(0, temp + lambda/mu); 100 | 101 | if norm(E_hat - temp_E, 'fro') < tolProj1 && norm(Z_hat - temp_Z)0))... 116 | ', stopCriterion ' num2str(stopCriterion)]); 117 | end 118 | 119 | if stopCriterion < tol 120 | break; 121 | end 122 | 123 | 124 | end 125 | 126 | end 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /gitlocal/LRR/exact_alm_lrr_l21v2.m: -------------------------------------------------------------------------------- 1 | function [Z_hat, E_hat] = exact_alm_lrr_l21v2(D, A, lambda, tol, maxIter,display) 2 | 3 | % Aug 2013 4 | % This matlab code implements the Exact ALM algorithm for 5 | % min_{Z,E} |Z|_* + lambda |E|_2,1 s.t. D = AZ + E 6 | % 7 | % D - m x n matrix of observations/data (required input) 8 | % A - m x k matrix of the dictionary (required input) 9 | 10 | % lambda - weight on sparse error term in the cost function 11 | % 12 | % tol - tolerance for stopping criterion. 13 | % - DEFAULT 1e-7 if omitted or -1. 14 | % 15 | % maxIter - maximum number of iterations 16 | % - DEFAULT 1000, if omitted or -1. 17 | % 18 | [m n] = size(D); 19 | k = size(A,2); 20 | 21 | 22 | if nargin < 4 || isempty(tol) 23 | tol = 1e-7; 24 | end 25 | 26 | if nargin < 5 || isempty(maxIter) 27 | maxIter = 1000; 28 | end 29 | 30 | if nargin<6 || isempty(display) 31 | display = false; 32 | end 33 | 34 | maxIter_primal = 10000; 35 | % initialize 36 | Y = sign(D); 37 | norm_two = norm(Y,2); 38 | norm_inf = norm( Y(:), inf) / lambda; 39 | dual_norm = max(norm_two, norm_inf); 40 | Y = Y / dual_norm; 41 | 42 | W = zeros(k,n); 43 | 44 | Z_hat = zeros(k,n); 45 | E_hat = zeros(m,n); 46 | %parameters 47 | dnorm = norm(D, 'fro'); 48 | tolProj1 = 1e-6 * dnorm; 49 | 50 | anorm = norm(A,2); 51 | tolProj2 = 1e-6 * dnorm/anorm; 52 | 53 | mu = .5/norm_two; % this one can be tuned 54 | rho = 6; % this one can be tuned 55 | 56 | %pre-computation 57 | if m>=k 58 | inv_ata = inv(eye(k) + A'*A); 59 | else 60 | inv_ata = eye(k) - A'/(eye(m)+A*A')*A; 61 | end 62 | 63 | iter = 0; 64 | while iter < maxIter 65 | iter = iter + 1; 66 | 67 | % solve the primal problem by alternative projection 68 | primal_iter = 0; 69 | 70 | while primal_iter < maxIter_primal 71 | primal_iter = primal_iter + 1; 72 | temp_Z = Z_hat; 73 | temp_E = E_hat; 74 | 75 | %update J 76 | temp = temp_Z + W/mu; 77 | [U S V] = svd(temp, 'econ'); 78 | 79 | diagS = diag(S); 80 | svp = length(find(diagS > 1/mu)); 81 | diagS = max(0,diagS - 1/mu); 82 | 83 | if svp < 0.5 %svp = 0 84 | svp = 1; 85 | end 86 | J_hat = U(:,1:svp)*diag(diagS(1:svp))*V(:,1:svp)'; 87 | 88 | % update Z 89 | temp = J_hat + A'*(D - temp_E) + (A'*Y-W)/mu; 90 | Z_hat = inv_ata*temp; 91 | 92 | %update E 93 | temp = D - A*Z_hat + Y/mu; 94 | E_hat = solve_l1l2(temp, lambda/mu); 95 | 96 | if norm(E_hat - temp_E, 'fro') < tolProj1 && norm(Z_hat - temp_Z)0))... 111 | ', stopCriterion ' num2str(stopCriterion)]); 112 | end 113 | 114 | if stopCriterion < tol 115 | break; 116 | end 117 | 118 | 119 | end 120 | 121 | end 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /gitlocal/LRR/inexact_alm_lrr_l1.m: -------------------------------------------------------------------------------- 1 | function [Z,E] = inexact_alm_lrr_l1(X,A,lambda,display) 2 | % This routine uses Inexact ALM algorithm to solve the following nuclear-norm optimization problem: 3 | % min |Z|_*+lambda*|E|_1 4 | % s.t., X = AZ+E 5 | % inputs: 6 | % X -- D*N data matrix, D is the data dimension, and N is the number 7 | % of data vectors. 8 | % A -- D*M matrix of a dictionary, M is the size of the dictionary 9 | 10 | if nargin<4 11 | display = false; 12 | end 13 | 14 | tol = 1e-6; 15 | maxIter =350 ; 16 | [d n] = size(X); 17 | m = size(A,2); 18 | rho = 1.1; 19 | max_mu = 1e10; 20 | mu = 1e-6; 21 | atx = A'*X; 22 | inv_a = inv(A'*A+eye(m)); 23 | %% Initializing optimization variables 24 | % intialize 25 | J = zeros(m,n); 26 | Z = zeros(m,n); 27 | E = sparse(d,n); 28 | 29 | Y1 = zeros(d,n); 30 | Y2 = zeros(m,n); 31 | 32 | %% Start main loop 33 | iter = 0; 34 | if display 35 | disp(['initial,rank=' num2str(rank(Z))]); 36 | end 37 | while iter1/mu)); 44 | if svp>=1 45 | sigma = sigma(1:svp)-1/mu; 46 | else 47 | svp = 1; 48 | sigma = 0; 49 | end 50 | J = U(:,1:svp)*diag(sigma)*V(:,1:svp)'; 51 | 52 | %udpate Z 53 | Z = inv_a*(atx-A'*E+J+(A'*Y1-Y2)/mu); 54 | [Uz,~,~]= svd(Z,'econ'); 55 | %update E 56 | xmaz = X-A*Z; 57 | temp = xmaz+Y1/mu; 58 | E = max(0,temp - lambda/mu)+min(0,temp + lambda/mu); 59 | leq1 = xmaz-E; 60 | leq2 = Z-J; 61 | stopC = max(max(max(abs(leq1))),max(max(abs(leq2)))); 62 | if display && (iter==1 || mod(iter,50)==0 || stopC1/mu)); 44 | if svp>=1 45 | sigma = sigma(1:svp)-1/mu; 46 | else 47 | svp = 1; 48 | sigma = 0; 49 | end 50 | J = U(:,1:svp)*diag(sigma)*V(:,1:svp)'; 51 | %udpate Z 52 | Z = inv_a*(atx-A'*E+J+(A'*Y1-Y2)/mu); 53 | %update E 54 | xmaz = X-A*Z; 55 | temp = xmaz+Y1/mu; 56 | E = solve_l1l2(temp,lambda/mu); 57 | 58 | leq1 = xmaz-E; 59 | leq2 = Z-J; 60 | stopC = max(max(max(abs(leq1))),max(max(abs(leq2)))); 61 | if display && (iter==1 || mod(iter,50)==0 || stopClambda 13 | x = (nw-lambda)*w/nw; 14 | else 15 | x = zeros(length(w),1); 16 | end 17 | end -------------------------------------------------------------------------------- /gitlocal/LRR/solve_lrr.m: -------------------------------------------------------------------------------- 1 | function [Z,E] = solve_lrr(X,A,lambda,reg,alm_type,display) 2 | % Aug 2013 3 | % This routine solves the following nuclear-norm optimization problem, 4 | % min |Z|_*+lambda*|E|_L 5 | % s.t., X = AZ+E 6 | % inputs: 7 | % X -- D*N data matrix, D is the data dimension, and N is the number 8 | % of data vectors. 9 | % A -- D*M matrix of a dictionary, M is the size of the dictionary 10 | % lambda -- parameter 11 | % reg -- the norm chosen for characterizing E, 12 | % -- reg=0 (default), use the l21-norm 13 | % -- reg=1 (or ther values except 0), use the l1-norm 14 | % alm_type -- 0 (default) use the exact ALM strategy 15 | % -- 1 use the inexact ALM strategy 16 | % 17 | X = double(X); 18 | A = double(A); 19 | if nargin < 6 || isempty(display) 20 | display = true; 21 | end 22 | if nargin<5 || isempty(alm_type) 23 | alm_type = 0 ; 24 | end 25 | 26 | if nargin<4 || isempty(reg) 27 | reg = 0; 28 | end 29 | 30 | Q = orth(A'); 31 | B = A*Q; 32 | 33 | if reg==0 34 | if alm_type ==0 35 | [Z,E] = exact_alm_lrr_l21v2(X,B,lambda,[],[],display); 36 | else 37 | [Z,E] = inexact_alm_lrr_l21(X,B,lambda,display); 38 | end 39 | else 40 | if alm_type == 0 41 | [Z,E] = exact_alm_lrr_l1v2(X,B,lambda,[],[],display); 42 | else 43 | [Z,E] = inexact_alm_lrr_l1(X,B,lambda,display); 44 | end 45 | end 46 | Z = Q*Z; 47 | end -------------------------------------------------------------------------------- /gitlocal/NLRRSS/NLRR.m: -------------------------------------------------------------------------------- 1 | 2 | function [U,V,obj,Time] = NLRR( Z,A,U,V,beta,k,epsilon) 3 | %NLRR Summary of this function goes here 4 | % min_U,V || Z - AUV^T ||_F^2 + \beta (|| U ||_F^2 + || V ||_F^2) 5 | % s.t. D = AU 6 | % stopping condition: epsilon 7 | %--------------Initializing---------- 8 | [m n] = size(Z); 9 | D = A*U; 10 | W = zeros(m,k); 11 | mu = 1e-4; 12 | maxiter = 15; 13 | obj = []; 14 | Time = []; 15 | Time = [Time 0]; 16 | sumTime = 0; 17 | %---------------Updating---------------- 18 | 19 | R = Z - A*U*V'; 20 | nowobj = 0.5*norm(R,'fro')^2 + 0.5*beta*norm(U,'fro')^2 + 0.5*beta*norm(V,'fro')^2; 21 | fprintf('Initialiazing obj %g :\n', nowobj); 22 | obj = [obj nowobj]; 23 | iter = 1; 24 | tic; 25 | totaltime = 0; 26 | converged = true; 27 | T_sec = 0; 28 | while converged 29 | tic; 30 | timebegin = cputime; 31 | U = inv(mu* A'*A + eye(n))* A'*(W + mu*D); 32 | V = Z'*D*inv(D'*D+ eye(k)/beta); 33 | D = (mu*A*U + beta*Z*V -W)* inv(beta*V'*V + mu* eye(k)); 34 | leq1 = D - A*U; 35 | T_sec = toc; 36 | sumTime = sumTime + T_sec; 37 | Time = [Time sumTime]; 38 | W = W + mu*leq1; 39 | mu = 1.1* mu; 40 | tempobj = nowobj; 41 | nowobj = 0.5*norm(Z-A*U*V', 'fro')^2+0.5*beta*norm(U,'fro')^2+0.5*beta*norm(V, 'fro')^2; 42 | obj = [obj nowobj]; 43 | totaltime = totaltime + (cputime - timebegin); 44 | fprintf('Iter %g Obj %g Diff %g Time %g \n', iter, nowobj,tempobj - nowobj, totaltime); 45 | if iter==1 46 | Decrease = tempobj - nowobj; 47 | end 48 | 49 | if iter == maxiter|| tempobj - nowobj >0 && tempobj - nowobj < epsilon*Decrease 50 | converged = false; 51 | end 52 | iter = iter +1; 53 | 54 | end 55 | toc; 56 | end 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /gitlocal/NLRRSS/NLRR.m~: -------------------------------------------------------------------------------- 1 | 2 | function [U,V,obj,Time] = NLRR( Z,A,U,V,beta,k,epsilon) 3 | %NLRR Summary of this function goes here 4 | % min_U,V || Z - AUV^T ||_F^2 + \beta (|| U ||_F^2 + || V ||_F^2) 5 | % s.t. D = AU 6 | % stopping condition: epsilon 7 | %--------------Initializing---------- 8 | [m n] = size(Z); 9 | D = A*U; 10 | W = zeros(m,k); 11 | mu = 1e-4; 12 | maxiter = 15; 13 | obj = []; 14 | Time = []; 15 | Time = [Time 0]; 16 | sumTime = 0; 17 | %---------------Updating---------------- 18 | 19 | R = Z - A*U*V'; 20 | nowobj = 0.5*norm(R,'fro')^2 + 0.5*beta*norm(U,'fro')^2 + 0.5*beta*norm(V,'fro')^2; 21 | fprintf('Initialiazing obj %g :\n', nowobj); 22 | obj = [obj nowobj]; 23 | iter = 1; 24 | tic; 25 | totaltime = 0; 26 | converged = true; 27 | T_sec = 0; 28 | while converged 29 | tic; 30 | timebegin = cputime; 31 | U = inv(mu* A'*A + eye(n))* A'*(W + mu*D); 32 | V = Z'*D*inv(D'*D+ eye(k)/beta); 33 | D = (mu*A*U + beta*Z*V -W)* inv(beta*V'*V + mu* eye(k)); 34 | eq1 = D - A*U; 35 | T_sec = toc; 36 | sumTime = sumTime + 37 | Time = [Time T_sec]; 38 | W = W + mu*leq1; 39 | mu = 1.1* mu; 40 | tempobj = nowobj; 41 | nowobj = 0.5*norm(Z-A*U*V', 'fro')^2+0.5*beta*norm(U,'fro')^2+0.5*beta*norm(V, 'fro')^2; 42 | obj = [obj nowobj]; 43 | totaltime = totaltime + (cputime - timebegin); 44 | fprintf('Iter %g Obj %g Diff %g Time %g \n', iter, nowobj,tempobj - nowobj, totaltime); 45 | if iter==1 46 | Decrease = tempobj - nowobj; 47 | end 48 | 49 | if iter == maxiter|| tempobj - nowobj >0 && tempobj - nowobj < epsilon*Decrease 50 | converged = false; 51 | end 52 | iter = iter +1; 53 | 54 | end 55 | toc; 56 | end 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /gitlocal/NLRRSS/NLRRE.m: -------------------------------------------------------------------------------- 1 | 2 | function [U,V,E,obj,Time] = NLRRE( Z,A,U,V,beta,k,epsilon,lambda) 3 | %NLRR Summary of this function goes here 4 | % min_U,V || Z - AUV^T ||_F^2 + \beta (|| U ||_F^2 + || V ||_F^2) 5 | % s.t. D = AU 6 | % stopping condition: epsilon 7 | %--------------Initializing---------- 8 | [m n] = size(Z); 9 | D = A*U; 10 | E = zeros(m,n); 11 | W = zeros(m,k); 12 | mu = 1e-4; 13 | maxiter = 7; 14 | obj = []; 15 | Time = []; 16 | Time = [Time 0]; 17 | %---------------Updating---------------- 18 | 19 | R = Z - A*U*V'; 20 | nowobj = 0.5*norm(R,'fro')^2 + 0.5*beta*norm(U,'fro')^2 + 0.5*beta*norm(V,'fro')^2; 21 | fprintf('Initialiazing obj %g :\n', nowobj); 22 | obj = [obj nowobj]; 23 | iter = 1; 24 | tic; 25 | totaltime = 0; 26 | converged = true; 27 | while converged 28 | 29 | timebegin = cputime; 30 | U = inv(mu* A'*A + eye(n))* A'*(W + mu*D); 31 | V = (Z-E)'*D*inv(D'*D+ eye(k)/beta); 32 | D = (mu*A*U + beta*Z*V -W)* inv(beta*V'*V + mu* eye(k)); 33 | E = max(Z - D*V'-lambda,0); 34 | leq1 = D - A*U; 35 | W = W + mu*leq1; 36 | mu = 1.1* mu; 37 | tempobj = nowobj; 38 | nowobj = 0.5*norm(Z-A*U*V', 'fro')^2+0.5*beta*norm(U,'fro')^2+0.5*beta*norm(V, 'fro')^2+ ... 39 | lambda* sum(sum(abs(E))); 40 | obj = [obj nowobj]; 41 | totaltime = totaltime + (cputime - timebegin); 42 | fprintf('Iter %g Obj %g Time %g\n', iter, nowobj, totaltime); 43 | if iter==1 44 | Decrease = tempobj - nowobj; 45 | end 46 | 47 | if tempobj - nowobj >0 && tempobj - nowobj < epsilon*Decrease || iter == maxiter 48 | converged = false; 49 | end 50 | iter = iter +1; 51 | 52 | end 53 | toc; 54 | end 55 | 56 | -------------------------------------------------------------------------------- /gitlocal/NLRRSS/NLRRplus.m: -------------------------------------------------------------------------------- 1 | function [U,V,obj,Time] = NLRRplus(Z,A,U,V,beta,k,epsilon, max_inner,nk,label) 2 | 3 | [m n] = size(Z); 4 | maxiter = 15; 5 | epsilon = 0.005; 6 | miniter = 7; 7 | iter = 1; 8 | R = Z - A*U*V'; 9 | nowobj = 0.5*norm(R,'fro')^2 + 0.5*beta*norm(U,'fro')^2 + 0.5*beta*norm(V,'fro')^2; 10 | fprintf('Initialiazing obj %g :\n', nowobj); 11 | obj = []; 12 | obj = [obj nowobj]; 13 | Time =[]; 14 | Time = [Time 0]; 15 | sumTime = 0; 16 | T_sec = 0; 17 | Q = A*A'; 18 | tic; 19 | [QU, QD] = svd(Q); 20 | toc; 21 | qd = diag(QD); 22 | ee = 1e-5; 23 | QUsub = QU(:, qd>=max(qd)*ee); 24 | qdsub = qd(qd>=max(qd)*ee); 25 | AT = A'; 26 | totaltime = 0; 27 | converged = true; 28 | while converged 29 | timebegin = cputime; 30 | tic; 31 | for tt=1:k% k is the estimated rank 32 | tempU = U; 33 | tempV = V; 34 | t = ceil(rand()*k); 35 | ut = U(:,t); 36 | vt = V(:,t); 37 | 38 | R = R + (A*ut)*vt'; 39 | for inneriter = 1:max_inner%inner iteration 40 | %% Update u_t 41 | Rvt = R*vt; 42 | QRvt = Q*Rvt; 43 | ARvt = AT*Rvt; 44 | ibeta = norm(vt)^2/beta; 45 | QsubQRvt =QUsub'*QRvt; 46 | SQsubQRvt=(1./(1+ibeta*qdsub)).*QsubQRvt; 47 | SSQsubQRvt =QUsub*SQsubQRvt; 48 | SSSQsubQRvt = AT*SSQsubQRvt; 49 | ut = (ibeta*ARvt - ibeta^2*SSSQsubQRvt)/(norm(vt)^2); 50 | %% Update v_t 51 | dt = norm(A*ut)^2; 52 | vt = ((ut'*AT)*R)'/(dt+beta); 53 | end 54 | R = R - (A*ut)*vt'; 55 | U(:,t) = ut; 56 | V(:,t) = vt; 57 | end 58 | T_sec = toc; 59 | sumTime = sumTime +T_sec; 60 | Time = [Time sumTime]; 61 | tempobj = nowobj; 62 | nowobj = 0.5*norm(R, 'fro')^2+0.5*beta*norm(U,'fro')^2+0.5*beta*norm(V, 'fro')^2; 63 | obj = [obj nowobj]; 64 | totaltime = totaltime + (cputime - timebegin); 65 | if iter==1 66 | Decrease = tempobj - nowobj; 67 | fprintf('Iter %g Decrease %g\n', iter, Decrease); 68 | end 69 | if iter == maxiter ||tempobj - nowobj >0 && tempobj - nowobj < epsilon*Decrease... 70 | || tempobj-nowobj<0&& iter>=4 71 | % if iter >=miniter && tempobj - nowobj < epsilon*Decrease 72 | converged = false; 73 | end 74 | if tempobj - nowobj<0 75 | U = tempU; 76 | V = tempV; 77 | end 78 | fprintf('Iter %g Obj %g Diff %g Time %g\n', iter, nowobj,tempobj - nowobj, totaltime); 79 | iter = iter + 1; 80 | end 81 | end 82 | 83 | 84 | -------------------------------------------------------------------------------- /gitlocal/NLRRSS/NLRRplus.m~: -------------------------------------------------------------------------------- 1 | function [U,V,obj,Time] = NLRRplus(Z,A,U,V,beta,k,epsilon, max_inner,nk,label) 2 | 3 | [m n] = size(Z); 4 | maxiter = 10; 5 | miniter = 5; 6 | iter = 1; 7 | R = Z - A*U*V'; 8 | nowobj = 0.5*norm(R,'fro')^2 + 0.5*beta*norm(U,'fro')^2 + 0.5*beta*norm(V,'fro')^2; 9 | fprintf('Initialiazing obj %g :\n', nowobj); 10 | obj = []; 11 | obj = [obj nowobj]; 12 | Time =[]; 13 | Time = [Time 0]; 14 | Q = A*A'; 15 | tic; 16 | [QU, QD] = svd(Q); 17 | toc; 18 | qd = diag(QD); 19 | ee = 1e-5; 20 | QUsub = QU(:, qd>=max(qd)*ee); 21 | qdsub = qd(qd>=max(qd)*ee); 22 | AT = A'; 23 | totaltime = 0; 24 | converged = true; 25 | while converged 26 | timebegin = cputime; 27 | 28 | for tt=1:k % k is the estimated rank 29 | t = ceil(rand()*k); 30 | ut = U(:,t); 31 | vt = V(:,t); 32 | R = R + (A*ut)*vt'; 33 | for inneriter = 1:max_inner %inner iteration 34 | %% Update u_t 35 | Rvt = R*vt; 36 | QRvt = Q*Rvt; 37 | ARvt = AT*Rvt; 38 | ibeta = norm(vt)^2/beta; 39 | QsubQRvt =QUsub'*QRvt; 40 | SQsubQRvt=(1./(1+ibeta*qdsub)).*QsubQRvt; 41 | SSQsubQRvt =QUsub*SQsubQRvt; 42 | SSSQsubQRvt = AT*SSQsubQRvt; 43 | ut = (ibeta*ARvt - ibeta^2*SSSQsubQRvt)/(norm(vt)^2); 44 | %% Update v_t 45 | dt = norm(A*ut)^2; 46 | vt = ((ut'*AT)*R)'/(dt+beta); 47 | end 48 | R = R - (A*ut)*vt'; 49 | U(:,t) = ut; 50 | V(:,t) = vt; 51 | end 52 | tempobj = nowobj; 53 | nowobj = 0.5*norm(R, 'fro')^2+0.5*beta*norm(U,'fro')^2+0.5*beta*norm(V, 'fro')^2; 54 | obj = [obj nowobj]; 55 | totaltime = totaltime + (cputime - timebegin); 56 | if iter==1 57 | Decrease = tempobj - nowobj; 58 | end 59 | % if iter == maxiter||tempobj - nowobj >0 && tempobj - nowobj < epsilon*Decrease 60 | if iter >=miniter && tempobj - nowobj < epsilon*Decrease 61 | converged = false; 62 | end 63 | fprintf('Iter %g Obj %g Time %g\n', iter, nowobj, totaltime); 64 | iter = iter + 1; 65 | end 66 | end 67 | 68 | 69 | -------------------------------------------------------------------------------- /gitlocal/NLRRSS/NLRRplusE.m: -------------------------------------------------------------------------------- 1 | function [U,V,E] = NLRRplusE(Z,A,U,V,beta,k,epsilon,max_inner,lambda) 2 | % min_{U,V,E} 0.5*||Z -AUV'-E||_F^2 + 0.5*beta||U||_F^2 + 0.5*beta||V||_F^2 3 | % + lambda * ||E||_1 4 | [m n] = size(Z); 5 | maxiter = 7; 6 | iter = 1; 7 | E = zeros(m,n); 8 | R = Z - A*U*V'-E; 9 | nowobj = 0.5*norm(R,'fro')^2 + 0.5*beta*norm(U,'fro')^2 + 0.5*beta*norm(V,'fro')^2; 10 | fprintf('Initialiazing obj %g :\n', nowobj); 11 | I = eye(m); 12 | Q = A*A'; 13 | tic; 14 | [QU, QD] = svd(Q); 15 | toc; 16 | qd = diag(QD); 17 | ee = 1e-5; 18 | QUsub = QU(:, qd>=max(qd)*ee); 19 | qdsub = qd(qd>=max(qd)*ee); 20 | AT = A'; 21 | totaltime = 0; 22 | converged = true; 23 | while converged 24 | timebegin = cputime; 25 | for tt=1:k 26 | t = ceil(rand()*k); 27 | ut = U(:,t); 28 | vt = V(:,t); 29 | R = R + (A*ut)*vt'; 30 | for inneriter = 1:max_inner 31 | %% Update u_t 32 | Rvt = R*vt; 33 | QRvt = Q*Rvt; 34 | ARvt = AT*Rvt; 35 | ibeta = norm(vt)^2/beta; 36 | QsubQRvt =QUsub'*QRvt; 37 | SQsubQRvt=(1./(1+ibeta*qdsub)).*QsubQRvt; 38 | SSQsubQRvt =QUsub*SQsubQRvt; 39 | SSSQsubQRvt = AT*SSQsubQRvt; 40 | ut = (ibeta*ARvt - ibeta^2*SSSQsubQRvt)/(norm(vt)^2); 41 | %% Update v_t 42 | dt = norm(A*ut)^2; 43 | vt = ((ut'*AT)*R)'/(dt+beta); 44 | end 45 | R = R - (A*ut)*vt'; 46 | U(:,t) = ut; 47 | V(:,t) = vt; 48 | end 49 | %% Update E and R: 50 | tempE = E; 51 | R = R + tempE; 52 | E = max(R-lambda,0); 53 | R = R - E; 54 | 55 | tempobj = nowobj; 56 | nowobj = 0.5*norm(R, 'fro')^2+0.5*beta*norm(U,'fro')^2+0.5*beta*norm(V, 'fro')^2+ lambda*sum(sum(abs(E))); 57 | totaltime = totaltime + (cputime - timebegin); 58 | if iter==1 59 | Decrease = tempobj - nowobj; 60 | end 61 | if tempobj - nowobj>0 && tempobj - nowobj < epsilon*Decrease || iter == maxiter 62 | converged = false; 63 | end 64 | fprintf('Iter %g Rank %g Obj %g Time %g\n', iter, t, nowobj, totaltime); 65 | iter = iter +1; 66 | end 67 | end 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /gitlocal/OLRSC/OLRR_solve_D.m: -------------------------------------------------------------------------------- 1 | function [ D ] = OLRR_solve_D( D, M, A, B, lambda1, lambda3 ) 2 | 3 | d = size(D, 2); 4 | 5 | I = eye(d, d); 6 | 7 | A_hat = lambda1 * A + lambda3 * I; 8 | B_hat = lambda1 * B + lambda3 * M; 9 | 10 | for j=1:d 11 | dj = D(:, j); 12 | aj = A_hat(:, j); 13 | bj = B_hat(:, j); 14 | 15 | tmp = dj - (D * aj - bj) / A_hat(j, j); 16 | 17 | D(:, j) = tmp; 18 | end 19 | 20 | end 21 | 22 | -------------------------------------------------------------------------------- /gitlocal/OLRSC/OLRR_solve_main.m: -------------------------------------------------------------------------------- 1 | function [ D, U, V, E ] = OLRR_solve_main( Z, lambda1, lambda2, lambda3, D, M, A, B ) 2 | 3 | [p, n] = size(Z); 4 | d = size(D, 2); 5 | 6 | U = zeros(n, d); 7 | V = zeros(n, d); 8 | E = zeros(p, n); 9 | 10 | for t=1:n 11 | if mod(t, 100) == 0 12 | fprintf('OLRR access sample %d\n', t); 13 | end 14 | 15 | z = Z(:, t); 16 | 17 | [v, e] = OLRR_solve_ve(z, D, lambda1, lambda2); 18 | 19 | normz = norm(z); 20 | u = (D - M)' * z / (normz * normz + 1/lambda3); 21 | 22 | M = M + z * u'; 23 | A = A + v * v'; 24 | B = B + (z-e) * v'; 25 | 26 | D = OLRR_solve_D(D, M, A, B, lambda1, lambda3); 27 | 28 | U(t, :) = u'; 29 | V(t, :) = v'; 30 | E(:, t) = e; 31 | end 32 | 33 | -------------------------------------------------------------------------------- /gitlocal/OLRSC/OLRR_solve_ve.m: -------------------------------------------------------------------------------- 1 | function [ v, e ] = OLRR_solve_ve( z, D, lambda1, lambda2 ) 2 | 3 | [p, d] = size(D); 4 | I = eye(d, d); 5 | 6 | aux = (D' * D + 1/lambda1 * I) \ D'; 7 | thd = lambda2 / lambda1; 8 | 9 | v = zeros(d, 1); 10 | e = zeros(p, 1); 11 | 12 | eps = 1e-3; 13 | maxIter = 1e3; 14 | 15 | converge = false; 16 | iter = 0; 17 | 18 | while ~converge 19 | iter = iter + 1; 20 | 21 | orgv = v; 22 | orge = e; 23 | 24 | v = aux * (z - e); 25 | e = wthresh(z - D * v, 's', thd); 26 | 27 | stopc = max(norm(v - orgv) / norm(v), norm(e - orge) / norm(e)); 28 | 29 | if stopc < eps || iter > maxIter 30 | converge = true; 31 | end 32 | end 33 | end 34 | 35 | -------------------------------------------------------------------------------- /gitlocal/ORPCA/ORPCA_new.m: -------------------------------------------------------------------------------- 1 | function [ L,R,E ] = ORPCA_new( Z,L,R,k, lambda,beta,epsilon,update,inneriter) 2 | % min 0.5*|| Z - LR^T ||F + 0.5*lambda||L||F+ 0.5*lambda||R||F 3 | % + beta*||E||_1 4 | %% Initializing: 5 | [m,n] = size(Z); 6 | % L = randn(m,k); 7 | % R = randn(n,k); 8 | E = zeros(m,n); 9 | S = Z - L*R' -E; 10 | maxiter = 8; 11 | iter = 1; 12 | converged = true; 13 | stopnorm = 0.5* norm(S,'fro')^2 + 0.5*lambda*norm(L,'fro')^2+ 0.5*lambda*norm(R,'fro')^2 ... 14 | + beta*sum(sum(abs(E))); 15 | fprintf( 'Initializing: obj_value = %g\n', stopnorm); 16 | 17 | %% 18 | switch(update) 19 | case 'column' 20 | while converged 21 | for i = 1: k 22 | S = S + L(:,i)*R(:,i)'; 23 | for inner = 1:inneriter 24 | L(:,i) =S*R(:,i)./ (lambda+ norm(R(:,i))^2); 25 | % L(:,i) =S*R(:,i)./ (lambda+ 1); 26 | R(:,i) =S'*L(:,i)./ (lambda+ norm(L(:,i))^2); 27 | % R(:,i) = R(:,i)./ norm(R(:,i)); 28 | end 29 | S = S - L(:,i)*R(:,i)'; 30 | end 31 | E = max(Z-S-beta,0); 32 | tempstop = stopnorm; 33 | stopnorm = 0.5* norm(S,'fro')^2 + 0.5*lambda*norm(L,'fro')^2+ 0.5*lambda*norm(R,'fro')^2 ... 34 | +beta*sum(sum(abs(E))); 35 | if iter==1 36 | Decrease = tempstop - stopnorm; 37 | end 38 | if iter == maxiter||tempstop-stopnorm >0 && tempstop-stopnorm< epsilon*Decrease 39 | converged = false; 40 | end 41 | fprintf('iter = %g, obj_value = %g \n',iter, stopnorm); 42 | iter = iter+1; 43 | end 44 | case 'matrix' 45 | inneriter =1; 46 | while converged 47 | for i = 1: k 48 | S = S + L(:,i)*R(:,i)'; 49 | for inner = 1:inneriter 50 | L(:,i) =S*R(:,i)./ (lambda+ norm(R(:,i))^2); 51 | % R(:,i) =S'*L(:,i)./ (lambda+ norm(L(:,i))^2); 52 | end 53 | S = S - L(:,i)*R(:,i)'; 54 | end 55 | for i = 1: k 56 | S = S + L(:,i)*R(:,i)'; 57 | for inner = 1:inneriter 58 | % L(:,i) =S*R(:,i)./ (lambda+ norm(R(:,i))^2); 59 | R(:,i) =S'*L(:,i)./ (lambda+ norm(L(:,i))^2); 60 | end 61 | S = S - L(:,i)*R(:,i)'; 62 | end 63 | E = max(Z-S-beta,0); 64 | tempstop = stopnorm; 65 | stopnorm = 0.5* norm(S,'fro')^2 + 0.5*lambda*norm(L,'fro')^2+ 0.5*lambda*norm(R,'fro')^2 ... 66 | +beta*sum(sum(abs(E))); 67 | if iter==1 68 | Decrease = tempstop - stopnorm; 69 | end 70 | if iter == maxiter||tempstop-stopnorm >0 && tempstop-stopnorm< epsilon*Decrease 71 | converged = false; 72 | end 73 | fprintf('iter = %g, obj_value = %g \n',iter, stopnorm); 74 | iter = iter+1; 75 | end 76 | 77 | 78 | end 79 | 80 | end 81 | 82 | -------------------------------------------------------------------------------- /gitlocal/ORPCA/ORPCA_new.m~: -------------------------------------------------------------------------------- 1 | function [ L,R,E ] = ORPCA_new( Z, k, lambda,beta ) 2 | % min 0.5*|| Z - LR^T ||F + 0.5*lambda||L||F+ 0.5*lambda||R||F 3 | % + beta*||E||_1 4 | %% Initializing: 5 | [m,n] = size(Z); 6 | L = randn(m,k); 7 | R = randn(n,k); 8 | E = zeros(m,n); 9 | S = Z - L*R' -E; 10 | maxiter = 8; 11 | inneriter = 3; 12 | iter = 1; 13 | converged = true; 14 | stopnorm = 0.5* norm(S,'fro')^2 + 0.5*lambda*norm(L,'fro')^2+ 0.5*lambda*norm(R,'fro')^2... 15 | + beta*sum(sum(abs(E))); 16 | %% 17 | while converged 18 | for i = 1: k 19 | S = S + L(:,i)*R(:,i)'; 20 | for inner = 1:inneriter 21 | L(:,i) =S*R(:,i)./ (lambda+ norm(R(:,i))^2); 22 | R(:,i) =S'*L(:,i)./ (lambda+ norm(L(:,i))^2); 23 | end 24 | S = S - L(:,i)*R(:,i)'; 25 | end 26 | E = max(Z-S-beta,0); 27 | iter = iter+1; 28 | tempstop = stopterm; 29 | stopterm = 0.5* norm(S,'fro')^2 + 0.5*lambda*norm(L,'fro')^2+ 0.5*lambda*norm(R,'fro')^2... 30 | +beta*sum(sum(abs(E))); 31 | if iter==1 32 | Decrease = tempstop - stopterm; 33 | end 34 | if iter == maxiter||tempstop-stopterm >0 && tempstop- nowobj < epsilon*Decrease 35 | converged = false; 36 | end 37 | end 38 | 39 | 40 | 41 | 42 | end 43 | 44 | -------------------------------------------------------------------------------- /gitlocal/ORPCA/solve_proj2.m: -------------------------------------------------------------------------------- 1 | % solve the problem: 2 | % min_{x,e} 0.5*|z-Dx-e|_2^2 + 0.5*lambda1*|x|_2^2 + lambda2*|e|_1 3 | % 4 | % solve the projection by APG 5 | % input: 6 | % z - data point 7 | % D - basis matrix 8 | % lambda1, lambda2 - tradeoff parameters 9 | % output: 10 | % r - projection coefficient 11 | % e - sparse noise 12 | % copyright Jiashi Feng (jshfeng@gmail.com) 13 | % 14 | function [x,e] = solve_proj2(z,D,lambda1,lambda2) 15 | 16 | % initialization 17 | [ndim,ncol] = size(D); 18 | e = zeros(ndim,1); 19 | x = zeros(ncol,1); 20 | I = eye(ncol); 21 | converged = false; 22 | maxIter = inf; 23 | iter = 0; 24 | % alternatively update 25 | DDt = inv(D'*D+lambda1*I)*D'; 26 | while ~converged 27 | iter = iter + 1; 28 | xtemp = x; 29 | x = DDt*(z-e); 30 | % x = (D'*D + lambda1*I)\(D'*(z-e)); 31 | etemp = e; 32 | e = thres(z-D*x,lambda2); 33 | stopc = max(norm(e-etemp), norm(x-xtemp))/ndim; 34 | if stopc < 1e-6 || iter > maxIter 35 | converged = true; 36 | end 37 | % fval = func_proj(z,D,lambda1,lambda2,x,e); 38 | % fprintf('fval = %f\n', fval); 39 | end 40 | 41 | end 42 | 43 | function x = thres(y,mu) 44 | x = max(y-mu, 0); 45 | x = x + min(y + mu, 0); 46 | end 47 | 48 | function fval = func_proj(z,D,lambda1,lambda2,x,e) 49 | fval = 0; 50 | fval = fval + 0.5*norm(z-D*x-e)^2; 51 | fval = fval + 0.5*lambda1*norm(x)^2; 52 | fval = fval + lambda2*sum(abs(e)); 53 | end -------------------------------------------------------------------------------- /gitlocal/ORPCA/stoc_rpca.m: -------------------------------------------------------------------------------- 1 | % Stochastic optimization for the robust PCA 2 | % Input: 3 | % D: [m x n] data matrix, m - ambient dimension, n - samples number 4 | % lambda1, lambda2: trade-off parameters 5 | % nrank: the groundtruth rank of the data 6 | % Output: 7 | % L: [m x r] the basis of the subspace 8 | % R: [r x n] the coefficient of the samples on the basis L 9 | % E: sparse error 10 | % 11 | % copyright (c) Jiashi Feng (jshfeng@gmail.com) 12 | % 13 | 14 | function [L,R,E] = stoc_rpca(D, nrank, lambda1, lambda2 ) 15 | 16 | 17 | %% initialization 18 | [ndim, nsample] = size(D); 19 | L = cell(nsample+1,1); 20 | L{1} = rand(ndim,nrank); 21 | A = zeros(nrank,nrank); 22 | B = zeros(ndim,nrank); 23 | R = zeros(nrank,nsample); 24 | E = zeros(ndim,nsample); 25 | 26 | %% online optimization 27 | for t = 1:nsample 28 | 29 | if mod(t, 100) == 0 30 | fprintf('OR-PCA: access sample %d\n', t); 31 | end 32 | % tic; 33 | z = D(:,t); 34 | % tic; 35 | [r,e] = solve_proj2(z,L{t},lambda1,lambda2); 36 | % tused = toc; 37 | % fprintf('elapsed time for projection %f secs\n',tused); 38 | R(:,t) = r; 39 | E(:,t) = e; 40 | 41 | A = A + r*r'; 42 | B = B + (z-e)*r'; 43 | % L{t+1} = update_col_orpca(L{t},A,B,lambda1/nsample); 44 | L{t+1} = update_col_orpca(L{t},A,B,lambda1); 45 | end 46 | 47 | R = R'; 48 | 49 | end 50 | 51 | -------------------------------------------------------------------------------- /gitlocal/ORPCA/update_col_orpca.m: -------------------------------------------------------------------------------- 1 | function L = update_col_orpca(L,A,B,lambda1) 2 | [junk,ncol] = size(L); 3 | A = A + lambda1*eye(ncol,ncol); 4 | for j = 1:ncol 5 | bj = B(:,j); 6 | lj = L(:,j); 7 | aj = A(:,j); 8 | temp = (bj-L*aj)/A(j,j) + lj; 9 | L(:,j) = temp/max(norm(temp),1); 10 | end 11 | end -------------------------------------------------------------------------------- /gitlocal/README.md: -------------------------------------------------------------------------------- 1 | # subspace-clustering in the '/gitlocal' folder 2 | 3 | Experimental code for comparing our new algorithm for subspace clustering---'NLRR++' with other existing methods. 4 | 5 | 1. Subspace clustering methods are organized in folders '~/ORPCA, ~/OLRSC, ~/LRR, ~/SSC, ~/NLRRSS' 6 | 7 | 2. NLRR ('NLRR.m', 'NLRRE.m') and NLRR++ ('NLRRplus.m', 'NLRRplusE.m') functions are displayed in the folder'~/NLRRSS'. 8 | 9 | 3. Code for running experiments are named as 'test**.m' which can be executed directly. 10 | 11 | 4. Datasets: 'Imagenet'(features trained by CNN), 'MNIST', 'SVHN', 'USPS', 'Protein'. 12 | 13 | 5. Clustering baseline and evaluation metric function are in the '~/clusterings' folder. 14 | 15 | 6. Competing methods: 16 | 17 | (1) NLRR:Jie Shen and Ping Li. 2016. Learning structured low-rank representation via matrix factorization. In Proceedings of the 19th International Conference on Arti€cial Intelligence and Statistics (ICAIS). 500–509 18 | 19 | (2) OLRSC:Jie Shen, Ping Li, and Huan Xu. 2016. Online Low-Rank Subspace Clustering by 20 | Basis Dictionary Pursuit. In Proceedings of the 33rd International Conference on Machine Learning (ICML). 622–631 21 | 22 | (3) LRR: Guangcan Liu, Zhouchen Lin, and Yong Yu. 2010. Robust subspace segmentation by low-rank representation. In Proceedings of the 27th international conference on machine learning (ICML). 663–670. 23 | 24 | (4) SSC:Ehsan Elhamifar and Rene Vidal. 2013. Sparse subspace clustering: Algorithm, theory, and applications. IEEE transactions on paˆern analysis and machine intelligence 35, 11 (2013), 2765–2781. 25 | 26 | (5) ORPCA:Jiashi Feng, Huan Xu, and Shuicheng Yan. 2013. Online robust pca via stochastic optimization. In Advances in Neural Information Processing Systems. 404–412 27 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_mul/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:59d65d29a7c42448ddbc0e6c0ca6ec95560afa15806c9277c3569421f4609bd7 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_mul/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d607461927983f60e14ef252ea13afd68f1cd0334f5f41606376fa67eed929d5 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_mul/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b33cb97e0e884805fc4dd51ab9aac358a7d2e85fb6a4c97674e1658c1533bdad 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_mul/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9767f57e02ecb7a7ae3a606f943cec72dedf91eebee0a0866ec8e91b25c8b1f3 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_mul/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8053cea787f77447af1a5a38c5f6da8a0d1818ad57c4b6d994ed685b66f78459 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_mul/ssc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4e0d760a429200442cea3c422257dda67db5fd48278d4fbfedc234451d72d1ab 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_sin/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6c00056773becde64ca97eecff8f7e09b0037060a53417ae965f585aa6c9e261 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_sin/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0e24e6ecf4b4ef80a7f3cdc180e912d3506f02ef123baf6d1d44ef757969e397 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_sin/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f55fd8ae05e994e7a4e746d29c38a1bd93e75650958d0b8c6eef09a78c9d73d5 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_sin/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9460f51c1f5f14b739f6dff2142f47bd92bab7bd41aa58b50c8366238a8edb5a 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/Protein_sin/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:89c727977db2b53501168301bc871da8a25bc2edbab24aaecc02f24d169deefb 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/lrr1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4ab264574022dd62bc2226f461b854dbc3f8dc37c7b3e4b41f40c8e10fce14e5 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/lrr1_327.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f1c6caabebe261bb8da5b14b99af36c921f02b9d497a28e530c4540f62b8168a 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/lrr1_62.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:38600cf8836f777a06e1f5bd6321d3b55d29619296cb9e4d606344cdf12d75ab 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/lrr2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:029956cad03c008a3cacdc5d7cc5683aa9ca77871ad0390d6038eac6f1725a0f 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrr1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:87f57a9a8e92d807435996a78fafd8e094d7072f2f6fb9c3b08ea44356157d5b 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrr1_327.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:076c89850693a32d71df356d9c9f8de4a55ac9ad8bcc0af40f97969237b18ba5 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrr1_62.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3ee03a971cece62251d2b6175c572efa66261c60e0a2b5d02c5c98ce317dc64b 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrr2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e7c823e03b21003fefe13394682e8c84fd1f864cd156029a6c22b93b5fbdf7e6 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrrp1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f9e7fc6eb1e6f271df382e43ffaf77d5f34dbc3f347f5e3c6e532fce3af6566d 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrrp1_327.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1d3e9341592ce4e2d9d0b7198bb37371d21f6af2f54cc32fa6d03b2ff76978f9 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrrp1_62.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4e1e8e604d8ffbeb37aff534fcfb8384f85893e0e4908c089e49cb528457eae7 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/nlrrp2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6557c4f54dca220459ed664517f7783ffdda62969e44034e192267a2619f7a98 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/olrsc1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c3ddc72e70070e3c96442a3a8287e937ad4ddf2975a7a5b78a2eb68e98b06b78 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/olrsc1_327.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7530e7b8b29d6e5eaecbfb09cfce6b4c7217e3206b8b448a6a1aa812ec321ff3 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/olrsc1_62.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:19b4e4dc6901199783b414229b4a14e3d07239fd1f8c88e40287b07bdaa69fc4 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/orpca1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:600f3cb1fca6595cad109304db51f4fba48f19cb60fdb06724e23e92d36a5c52 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/orpca1_327.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:09262d413cd662da3e76b845515f5e31c94ac7dd52f3ba152f607b49b968d303 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_mul/orpca1_62.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e20db01d09cfb01a9dae6a3f8b1d25c8e510891b05ca0773faf7a04da638cafe 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/lrr1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a87bcf62cf088d5aa908bdab06592def182a2a5239d637fc9a8ad0b31fafcaa1 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/lrr2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:be52dda27e932383d4bc0931c0ef505ed77aa3a6ce93d16a286005840daccf81 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/nlrr1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:52a28379c7bb78263eb857895b91041813c0d1c0a9d93073fbd7da1e9b570cb9 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/nlrr2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b88b73689a8dfe9418a9edbab22a81b82697521deec15be85980489901c72294 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/nlrrp1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:80cecbaf3bed13da82dc11135eb6b3051c7d4010d66cc4346e3d617e5135591c 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/nlrrp2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c07c24e0dfe6dcb26983a6613fe111e83bd0af11bb5a58863f1d839dffee64f2 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/olrsc1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:980865297ca8bbd063c83b18b32cbb464323ecb57140bcb949367bde60fb2c89 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/olrsc2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d7b150b9ce764ca78a4e5d51726be9a2f9a95a06a4dd3767e0830a154d9deb54 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/orpca1_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8b7014ad32ac50304032e66f232e8350144cd5b961beb61b0cc96c0a6f965ad3 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/imagenet_sin/orpca2_214.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ac93ee00792f99cf96b80c1cf523289627aeeb9f4725a9251ec899b653afeea2 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_conv/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:33cbb6d1ce9a31658f387d3f6bfc719da7242aec86c11169d24bb3cbc962b2fb 3 | size 381 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_conv/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0b0e0c3b38efae88ef2159696cc89ad9ec1e26c78278fa25a96061beac9193bf 3 | size 382 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_mul/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:301fdd3bda323136416eef46e36085c4fde0bb7930bc2a1279fd563317695567 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_mul/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4f20ed39f20de5b4af1cae1277260b3f455cc2f9524071194a689e275d10bdd2 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_mul/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0e4aac179d7300a1aeb28b807d9c96983188715ce608c8f3be7ce0401bc7458e 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_mul/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:752848b8b6d52b1d449c70a037f01c880b4bb13bc4dbb20c6ad1378210a8458c 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_mul/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4276ac585a0109e350a7e972f53eabf46294c14b338a54ba1aa0e767dca6fee9 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_mul/ssc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:94ada0b5ed4109a725dbdbf9a5fc8613a22c6c6cf6f8c605241871d7ce07137d 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_sin/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1fc26ccebd68921ba4dcfdf9119231d95fcf7ec926c9c0f3a206c1c0867b310e 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_sin/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:be48d0ba226bfa4c1c64c3100adc76a8512e639ffd176375ff97a5b0d9908754 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_sin/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fb5f3bb3c43589409fe4608bff206ed7eba83aef500526f5a8353fa6bbc28610 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_sin/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8db88995f7152cc34376db42576c3736f51ca02d1cffc0a050042ac39e5c69da 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/mnist_sin/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:def4a86bfecef64fdc200e8917c3c364d41e865f4ba632e5dca18168cb0116bf 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/protein_conv/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:880a9a0548376cdc1a7e93af63218697707deeb98f4c807442d076692ef2f042 3 | size 565 4 | -------------------------------------------------------------------------------- /gitlocal/Result/protein_conv/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8da18dfba6cb34a4eeec5903d7ea0b33f12fb0b3c5f9a5a9c88ef25619d05916 3 | size 412 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/2800lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0c759fb82fac6aed8073cde5f7bfc25abc503cdb68a71c4a04ae12228cb717c8 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/2800nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3223afaa2adb64ecc8b0566730bf8166d5caa4a69175385c8731bcaa94e3b696 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/2800nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4fa8981043e26ec3008649583b62b3f2391af19314827adfafb09010f2250211 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/2800olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:95e2b0ff69cc3b2ab43af437b2e566997bcef9f2956d44d882b21309bb1dfe5f 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/2800orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3134c6ddec109168522765dad57eba5ff17043a501a7f29134752dacc2d56e06 3 | size 262 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3200lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8c9a5e5690421705bbab1f40e7303cefdc20c243617b8b0f2ea243f9d7c2d48f 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3200nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6f5dc86f087ac416d1e250ced363cb9fd2a5f77ec0a63961b7ae112b5dd22830 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3200nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c6e48cf3342e432c4ebd2a86c0a0974205c4522b97c687813bb73fe95d41ce29 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3200olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:579ce3685e2f662962bd21904d6d74d6318576222aab5eda16e695c1b8d8a548 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3200orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:56ed7531465bc43df08afe0dd49344a6f6d7a4ecfff0aa677198dd80ec2dbdcb 3 | size 262 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3600lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7cbffd836477a92e74f5c013135563ad268fe18473677f25d05a8c5ed072c240 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3600nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ca77c87fc338e7d23a7b4005b06e6aef42e9b87c5c64033ff6f6ec44a0c74a5c 3 | size 251 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3600nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:943c88844f342a3660f5b719cadb6c218d284ac8781460c88b6777de7afe5a74 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3600olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aa84fd83268b27fb11f103f98a2edb0837cf992974738b63afe3f409d756242c 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/3600orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bb5ad374431c0317c13e30ec95c8458d3ce76fb32ba9c3df2db37540e541432d 3 | size 262 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/4000lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ee698c122f645381c39fa9e2e6223e688e5568ab81b2306d6e2333f5036cca1f 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/4000nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:05122647c41e4b4c4cdbe9c3466d05166edccb119460b88e0e954a8542b2511e 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/4000nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:02b3d9f2f6d823cf49c6fe97d17bcc09e7b2009e15be1f10ea0e0f06a4eb5810 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/4000olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:83a16a7af8819755bc6b5ec8357ab9fe51f7988404c0d32a8a41fce603c1bc3c 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/4000orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0a1d66aae478a44956337422012bcb0849e9239eef6ffc789379a2c80ba7aa29 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/40lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b4e8d3e56696ac3bcdebb05678fcb899d445efc16c183353885ead188918f6bc 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/40nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:062194cf2531059d5a9d207167b7c0c6f8642abf7499ea5aa47db76cc05a5a31 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/40nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a09a24d6390284278a1b5629b7bd41188c710919abc185bb9d7b9117849d6ea5 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/40olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5e43630a24f81ca794b80cff3d85e339547554b6d5ae9995c25efa8a3262f7fe 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/40orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dde697a2c98564021da96ded438de57ee16617444915e30a5081eaef9cb3b22a 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/4400nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c91314b7d740c25651c017c916bf5b03c5b75607b0e9df6fa01d1d9eb7d4c098 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/4400nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:88d43249e55be5e6a4db37b16a1b979de2c0b1e5a02b8a722112d91d5876a1a6 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/45lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ce0c6ea39a054301a87eaf0f15be6f9d8126026e3849bb39f6779278442e54e0 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/45nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:af4225a505f206ebdd3efba09e7b2664ac01b4ce72eefeaf32c47796667b7852 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/45nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e433bf6b34d9fa679c927bbd1b7636e789aa9c4b2ad3c6534518eb4aec149ddd 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/45olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:da7a9fe5173d68087e78e004dc114656eee9149baa5edde0baf5c4d491ed504d 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/45orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b95bfea40d1020da05315b5a0858f14021b95a4bea6cbbb72d75ae954c8e682f 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/50lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ddaa1eac5351e6e5bea3651fcdf4bdc20e8390e3be32073690920cb5068cc34d 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/50nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:52d4c1d71fb03053feba70957d139ee458511b425057c7c6190f93b3bbad89d3 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/50nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:87aa0b29d8c84182a3738df8d1a60472fef434c86350fa473dad2d27df9fafd4 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/50olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:85589908733f1b0d99057c681f38365e8892839c8f1532ae7f87b8bdb1d30b57 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/50orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:100ebd394bf9dedf50807c36670c973eae2603ff91353cfb17c98dc6fc7b649e 3 | size 262 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/55lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:12e99fb5ca095baa7f5e756650cff7b8f0596fee34df22fa8ee88c0ff6f74d5d 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/55nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d644d475684c4090a2a175aaf275b786a3ac1ce264781af53fcfccb96b472596 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/55nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:694bdd18b6ab270958ba223d11caecd6cb2de75b6ddaab0daed7d9a54634ade2 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/55olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:829f72d07532ac1c5b0effb1c09f4aba1e8e7c416a29acbba5121b95aaef3020 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/55orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e3a842171fc00d6c79389caf69ba6beef5329bd25f30577d4a50f68379cc4da5 3 | size 262 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/60lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a66743537e63fcc3171e250ae7bcfe8a699d1f5e42f09b5dd6f0e8d24bddfb58 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/60nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0b3d190d14298922948485da2a94d832aede198b1fb5ceaff12282016798ad8d 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/60nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:904e96fd3eb86deb520fdabd3fa49905eabcd0c65801c4d226320745e84863a3 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/60olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e35cf2c1bfa7c3a81ed9f801bd758226348cf3f1e5013c044da4c7d84719cf3d 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/60orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:72370dc8450fb14297a21043d26944f3c4a391a78e9d5c2a1482492bbac6a3fa 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/65lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f2bde6315d0be7971ae2b41b2bd7e92a256dfe568223b6a1050dd965efe0724d 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/65nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2b019d4a1d49dc739a8e5255054b2b33212c797ca2effd7434c3267bc532fc2a 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/65nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e558c7a730f5d4d31ec2db360d49e0138b750b3e505a09157d74e2dc89dc0810 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/65olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:84605e301efe33b46170be8233ba1f794f82824d91abc8b64fda62bd9aeaf6ad 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/65orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:847e4ae65f53f886c5f6dbf8e588d06e4d6efa65ea891f2a5f014cf896417dcf 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/70lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f0463e16e88801c8ba85d180598884d3b050a8886d692761244d39d3b75186c8 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/70nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:795fa19bada6664320d814d6fc85d08726bb05857ef00769cd08eafbc4b58013 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/70nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9a14e4a9022f83f8807ca096f9d70f01c7de09a7432953c041da682d013a4960 3 | size 248 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/70olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:97f0de12281814b8cd79d6efbf729fe489327c0a0f9676e41077f8b89b466b46 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/70orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:096af3d60cb945945c2c71fe66b1333444ca4c5aecfd8f0d148ae082c17dff97 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/75lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8e89aa1287cd903b7bdec7f3451487cb42f0128fc98199e0a47444705c3cd4b5 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/75nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4d9efd934f529adcda1391b3ec389765bc22e76803145305613dec5b13914d5f 3 | size 250 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/75nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:05e5ec0c5348ff80de59f07945bfb08e950a9e2b9b9a33330aee744fc1bc8a30 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/75olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9d4c8fc88dc154693cff877bd368010057408116091435453e86042f625bc523 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/75orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e398ccd6671d39c80df40494788c67ba1c27a1183c7de00d0e9d3b1d0e0a603c 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/80lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a770b7c3a3af9df51f3637b266168289ade6f9c0232bf21e361c9e91c5fcf361 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/80nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f60e28ca2bb38af353ca42a42523ad13ff8bb4e90d9a2aacb67b83ea7f2838e8 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/80nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5cbb6be24d37bb917bf529013634dc2e5a6a4075abc12a204e168518da734259 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/80olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:73dc814f0d480ce79aa09c32d56521027c0807985289ed305a908823cd064a35 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/80orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:894df6a7d0c08c2db74e855cca449007d0ec5481768437e2681486b9d72146ac 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/85lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ee852ab4b1d58c061e28ecb776070dc82065403b4d18cf3a2e0f97763eff6bf7 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/85nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0509dd158d831953503ea0f47edc83449752c7f9f5efa947a3d46b65546bce46 3 | size 248 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/85nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:01850e41ea06d021c2b1a8b90169f27cbb452e7258bed662ada288d71ed3e780 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/85olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fb2affc4ed779d0578e2f40cc0bf31d055438448942ee15dee4a4e79d7faa70b 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/85orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f2a3533787c098794a3ed4c519508a9f53e787b35b7f84dd278afea5de1e86b9 3 | size 261 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/90lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:68fb1f97e4607340b477c0b4fd95fa06870250252ffdf8a5ccd9eaeefc8106ce 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/90nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6e13f4e2f31059112f08558ec38b01bf788946bae502042f3628d3f6753f3e34 3 | size 248 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/90nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2b3e46bb306820c8b725241c8d2e0d91fa08f7ce4eee32769c623e07d861683e 3 | size 249 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/90olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:963d7d653711f5edb9c2020951704892355a2b7146def914b89830320f6b365d 3 | size 276 4 | -------------------------------------------------------------------------------- /gitlocal/Result/simulation_sin/90orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f54ef83310a298c9fb35994f875a163ec9276398830045c89edc87a758e5ad87 3 | size 262 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_conv/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:93c45e7e69e8557b120b86273a0b0693c2610c42b0a82982f6b9f12ea85437d1 3 | size 382 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_conv/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8bf458dfe0274a73911e312359495365d92ad105c8b3e61bbc332a2409e3ceb2 3 | size 381 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_mul/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a475e49cc89347073b31df47900250fdad26e37e5e7f7ad3cf7f51431ff840a5 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_mul/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b13bd1cc705f3bdafd0fab7c179f8d4b1faa22f67c3f8e0540f2f6687995a652 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_mul/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7808132d44346f7dc4c466283138533cae4b1ac4eeb57d8b496d391ffe7d62bc 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_mul/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dbb25968d70cacb78e3ccc80c86e751283a964fa34c52cf8059be102bca4ff5e 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_mul/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7a962ed7c3fda37fbc98aa1fb1c6639b4a107ce2c8beceac7ff0f24d638142c2 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_sin/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9f2c33d551efacfdde1012e8a569dacc254777a9fd5be6bbb13ffcce07df368c 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_sin/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d0120f4bf6876cbd2d09f20de545f0f4cc5bdbd1db67439b844435ce0fd0e6f3 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_sin/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:895d39f259a95a1afa3cd1907684a90f6a043258705c8ab3333b3fb33148fb25 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_sin/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8aff294c4374c8ae1caa0473816a0df3d5ee2f5cc5e8323d92d4b39abe12ec2c 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/svhn_sin/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4735a600358bb71a611cfee919e2f087604ab2cc6bd8e429c28659423021dfb6 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_mul/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fd10aaebc7b2382ad92d35c3cbe3462e05e3cbcd41e3b0f549955b625490b1fa 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_mul/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e284b129c12de76d8d78740e63e7ce2dfb5f62fedf54e6861567fba408a34865 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_mul/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:97caa372c2d81affe83186a26786c922106afc954f754a79a007aa728843b337 3 | size 281 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_mul/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a6d7e4375466e2efdc7d1773cf1307a0b7755050fae3460d03d6bc75e757e4f5 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_mul/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:98bf6c3770d761e8113939a15ab8fb3fb556ff49057a4ec7b8df1aa591ab1822 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_mul/ssc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:797394da5382ba634fc0262f0bfb3e6df21f3a67187788c22c34f61f647c7d9a 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_sin/lrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e51cf025ce1bbff986877198cfbd25aca0bd62bc628245cb91907c6a41ef859c 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_sin/nlrr.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e49548ec8cd4a595d1fd2334f992806de9e8e7316a5c7b823c7dafb10d941f56 3 | size 279 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_sin/nlrrp.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b23f534587135f37672c872c3d317ff6747e4502382d470b3ae7e27ddc7654cc 3 | size 280 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_sin/olrsc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:22d514e8ff0d438f6e2bc9c99b0467201a8a8e263ef1fad9592a326ecd099f9a 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_sin/orpca.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3d94c8d0514398d20794789b017d7d777a32e3a305c8e40492a87f7848676fe6 3 | size 282 4 | -------------------------------------------------------------------------------- /gitlocal/Result/usps_sin/ssc.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:67367a259af7a7b30a7a921f3e375c0be036def6360baedefd695a453c7e426e 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/SSC/BuildAdjacency.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function takes a NxN coefficient matrix and returns a NxN adjacency 3 | % matrix by choosing the K strongest connections in the similarity graph 4 | % CMat: NxN coefficient matrix 5 | % K: number of strongest edges to keep; if K=0 use all the exiting edges 6 | % CKSym: NxN symmetric adjacency matrix 7 | %-------------------------------------------------------------------------- 8 | % Copyright @ Ehsan Elhamifar, 2012 9 | %-------------------------------------------------------------------------- 10 | 11 | 12 | function [CKSym,CAbs] = BuildAdjacency(CMat,K) 13 | 14 | if (nargin < 2) 15 | K = 0; 16 | end 17 | 18 | N = size(CMat,1); 19 | CAbs = abs(CMat); 20 | 21 | [Srt,Ind] = sort( CAbs,1,'descend' ); 22 | 23 | if (K == 0) 24 | for i = 1:N 25 | CAbs(:,i) = CAbs(:,i) ./ (CAbs(Ind(1,i),i)+eps); 26 | end 27 | else 28 | for i = 1:N 29 | for j = 1:K 30 | CAbs(Ind(j,i),i) = CAbs(Ind(j,i),i) ./ (CAbs(Ind(1,i),i)+eps); 31 | end 32 | end 33 | end 34 | 35 | CKSym = CAbs + CAbs'; -------------------------------------------------------------------------------- /gitlocal/SSC/DataProjection.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function takes the D x N data matrix with columns indicating 3 | % different data points and project the D dimensional data into a r 4 | % dimensional subspace using PCA. 5 | % X: D x N matrix of N data points 6 | % r: dimension of the PCA projection, if r = 0, then no projection 7 | % Xp: r x N matrix of N projectred data points 8 | %-------------------------------------------------------------------------- 9 | % Copyright @ Ehsan Elhamifar, 2012 10 | %-------------------------------------------------------------------------- 11 | 12 | 13 | function Xp = DataProjection(X,r) 14 | 15 | if (nargin < 2) 16 | r = 0; 17 | end 18 | 19 | if (r == 0) 20 | Xp = X; 21 | else 22 | [U,~,~] = svd(X,0); 23 | Xp = U(:,1:r)' * X; 24 | end 25 | -------------------------------------------------------------------------------- /gitlocal/SSC/Hungarian.m: -------------------------------------------------------------------------------- 1 | function [Matching,Cost] = Hungarian(Perf) 2 | % 3 | % [MATCHING,COST] = Hungarian_New(WEIGHTS) 4 | % 5 | % A function for finding a minimum edge weight matching given a MxN Edge 6 | % weight matrix WEIGHTS using the Hungarian Algorithm. 7 | % 8 | % An edge weight of Inf indicates that the pair of vertices given by its 9 | % position have no adjacent edge. 10 | % 11 | % MATCHING return a MxN matrix with ones in the place of the matchings and 12 | % zeros elsewhere. 13 | % 14 | % COST returns the cost of the minimum matching 15 | 16 | % Written by: Alex Melin 30 June 2006 17 | 18 | 19 | % Initialize Variables 20 | Matching = zeros(size(Perf)); 21 | 22 | % Condense the Performance Matrix by removing any unconnected vertices to 23 | % increase the speed of the algorithm 24 | 25 | % Find the number in each column that are connected 26 | num_y = sum(~isinf(Perf),1); 27 | % Find the number in each row that are connected 28 | num_x = sum(~isinf(Perf),2); 29 | 30 | % Find the columns(vertices) and rows(vertices) that are isolated 31 | x_con = find(num_x~=0); 32 | y_con = find(num_y~=0); 33 | 34 | % Assemble Condensed Performance Matrix 35 | P_size = max(length(x_con),length(y_con)); 36 | P_cond = zeros(P_size); 37 | P_cond(1:length(x_con),1:length(y_con)) = Perf(x_con,y_con); 38 | if isempty(P_cond) 39 | Cost = 0; 40 | return 41 | end 42 | 43 | % Ensure that a perfect matching exists 44 | % Calculate a form of the Edge Matrix 45 | Edge = P_cond; 46 | Edge(P_cond~=Inf) = 0; 47 | % Find the deficiency(CNUM) in the Edge Matrix 48 | cnum = min_line_cover(Edge); 49 | 50 | % Project additional vertices and edges so that a perfect matching 51 | % exists 52 | Pmax = max(max(P_cond(P_cond~=Inf))); 53 | P_size = length(P_cond)+cnum; 54 | P_cond = ones(P_size)*Pmax; 55 | P_cond(1:length(x_con),1:length(y_con)) = Perf(x_con,y_con); 56 | 57 | %************************************************* 58 | % MAIN PROGRAM: CONTROLS WHICH STEP IS EXECUTED 59 | %************************************************* 60 | exit_flag = 1; 61 | stepnum = 1; 62 | while exit_flag 63 | switch stepnum 64 | case 1 65 | [P_cond,stepnum] = step1(P_cond); 66 | case 2 67 | [r_cov,c_cov,M,stepnum] = step2(P_cond); 68 | case 3 69 | [c_cov,stepnum] = step3(M,P_size); 70 | case 4 71 | [M,r_cov,c_cov,Z_r,Z_c,stepnum] = step4(P_cond,r_cov,c_cov,M); 72 | case 5 73 | [M,r_cov,c_cov,stepnum] = step5(M,Z_r,Z_c,r_cov,c_cov); 74 | case 6 75 | [P_cond,stepnum] = step6(P_cond,r_cov,c_cov); 76 | case 7 77 | exit_flag = 0; 78 | end 79 | end 80 | 81 | % Remove all the virtual satellites and targets and uncondense the 82 | % Matching to the size of the original performance matrix. 83 | Matching(x_con,y_con) = M(1:length(x_con),1:length(y_con)); 84 | Cost = sum(sum(Perf(Matching==1))); 85 | 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87 | % STEP 1: Find the smallest number of zeros in each row 88 | % and subtract that minimum from its row 89 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 90 | 91 | function [P_cond,stepnum] = step1(P_cond) 92 | 93 | P_size = length(P_cond); 94 | 95 | % Loop throught each row 96 | for ii = 1:P_size 97 | rmin = min(P_cond(ii,:)); 98 | P_cond(ii,:) = P_cond(ii,:)-rmin; 99 | end 100 | 101 | stepnum = 2; 102 | 103 | %************************************************************************** 104 | % STEP 2: Find a zero in P_cond. If there are no starred zeros in its 105 | % column or row start the zero. Repeat for each zero 106 | %************************************************************************** 107 | 108 | function [r_cov,c_cov,M,stepnum] = step2(P_cond) 109 | 110 | % Define variables 111 | P_size = length(P_cond); 112 | r_cov = zeros(P_size,1); % A vector that shows if a row is covered 113 | c_cov = zeros(P_size,1); % A vector that shows if a column is covered 114 | M = zeros(P_size); % A mask that shows if a position is starred or primed 115 | 116 | for ii = 1:P_size 117 | for jj = 1:P_size 118 | if P_cond(ii,jj) == 0 && r_cov(ii) == 0 && c_cov(jj) == 0 119 | M(ii,jj) = 1; 120 | r_cov(ii) = 1; 121 | c_cov(jj) = 1; 122 | end 123 | end 124 | end 125 | 126 | % Re-initialize the cover vectors 127 | r_cov = zeros(P_size,1); % A vector that shows if a row is covered 128 | c_cov = zeros(P_size,1); % A vector that shows if a column is covered 129 | stepnum = 3; 130 | 131 | %************************************************************************** 132 | % STEP 3: Cover each column with a starred zero. If all the columns are 133 | % covered then the matching is maximum 134 | %************************************************************************** 135 | 136 | function [c_cov,stepnum] = step3(M,P_size) 137 | 138 | c_cov = sum(M,1); 139 | if sum(c_cov) == P_size 140 | stepnum = 7; 141 | else 142 | stepnum = 4; 143 | end 144 | 145 | %************************************************************************** 146 | % STEP 4: Find a noncovered zero and prime it. If there is no starred 147 | % zero in the row containing this primed zero, Go to Step 5. 148 | % Otherwise, cover this row and uncover the column containing 149 | % the starred zero. Continue in this manner until there are no 150 | % uncovered zeros left. Save the smallest uncovered value and 151 | % Go to Step 6. 152 | %************************************************************************** 153 | function [M,r_cov,c_cov,Z_r,Z_c,stepnum] = step4(P_cond,r_cov,c_cov,M) 154 | 155 | P_size = length(P_cond); 156 | 157 | zflag = 1; 158 | while zflag 159 | % Find the first uncovered zero 160 | row = 0; col = 0; exit_flag = 1; 161 | ii = 1; jj = 1; 162 | while exit_flag 163 | if P_cond(ii,jj) == 0 && r_cov(ii) == 0 && c_cov(jj) == 0 164 | row = ii; 165 | col = jj; 166 | exit_flag = 0; 167 | end 168 | jj = jj + 1; 169 | if jj > P_size; jj = 1; ii = ii+1; end 170 | if ii > P_size; exit_flag = 0; end 171 | end 172 | 173 | % If there are no uncovered zeros go to step 6 174 | if row == 0 175 | stepnum = 6; 176 | zflag = 0; 177 | Z_r = 0; 178 | Z_c = 0; 179 | else 180 | % Prime the uncovered zero 181 | M(row,col) = 2; 182 | % If there is a starred zero in that row 183 | % Cover the row and uncover the column containing the zero 184 | if sum(find(M(row,:)==1)) ~= 0 185 | r_cov(row) = 1; 186 | zcol = find(M(row,:)==1); 187 | c_cov(zcol) = 0; 188 | else 189 | stepnum = 5; 190 | zflag = 0; 191 | Z_r = row; 192 | Z_c = col; 193 | end 194 | end 195 | end 196 | 197 | %************************************************************************** 198 | % STEP 5: Construct a series of alternating primed and starred zeros as 199 | % follows. Let Z0 represent the uncovered primed zero found in Step 4. 200 | % Let Z1 denote the starred zero in the column of Z0 (if any). 201 | % Let Z2 denote the primed zero in the row of Z1 (there will always 202 | % be one). Continue until the series terminates at a primed zero 203 | % that has no starred zero in its column. Unstar each starred 204 | % zero of the series, star each primed zero of the series, erase 205 | % all primes and uncover every line in the matrix. Return to Step 3. 206 | %************************************************************************** 207 | 208 | function [M,r_cov,c_cov,stepnum] = step5(M,Z_r,Z_c,r_cov,c_cov) 209 | 210 | zflag = 1; 211 | ii = 1; 212 | while zflag 213 | % Find the index number of the starred zero in the column 214 | rindex = find(M(:,Z_c(ii))==1); 215 | if rindex > 0 216 | % Save the starred zero 217 | ii = ii+1; 218 | % Save the row of the starred zero 219 | Z_r(ii,1) = rindex; 220 | % The column of the starred zero is the same as the column of the 221 | % primed zero 222 | Z_c(ii,1) = Z_c(ii-1); 223 | else 224 | zflag = 0; 225 | end 226 | 227 | % Continue if there is a starred zero in the column of the primed zero 228 | if zflag == 1; 229 | % Find the column of the primed zero in the last starred zeros row 230 | cindex = find(M(Z_r(ii),:)==2); 231 | ii = ii+1; 232 | Z_r(ii,1) = Z_r(ii-1); 233 | Z_c(ii,1) = cindex; 234 | end 235 | end 236 | 237 | % UNSTAR all the starred zeros in the path and STAR all primed zeros 238 | for ii = 1:length(Z_r) 239 | if M(Z_r(ii),Z_c(ii)) == 1 240 | M(Z_r(ii),Z_c(ii)) = 0; 241 | else 242 | M(Z_r(ii),Z_c(ii)) = 1; 243 | end 244 | end 245 | 246 | % Clear the covers 247 | r_cov = r_cov.*0; 248 | c_cov = c_cov.*0; 249 | 250 | % Remove all the primes 251 | M(M==2) = 0; 252 | 253 | stepnum = 3; 254 | 255 | % ************************************************************************* 256 | % STEP 6: Add the minimum uncovered value to every element of each covered 257 | % row, and subtract it from every element of each uncovered column. 258 | % Return to Step 4 without altering any stars, primes, or covered lines. 259 | %************************************************************************** 260 | 261 | function [P_cond,stepnum] = step6(P_cond,r_cov,c_cov) 262 | a = find(r_cov == 0); 263 | b = find(c_cov == 0); 264 | minval = min(min(P_cond(a,b))); 265 | 266 | P_cond(find(r_cov == 1),:) = P_cond(find(r_cov == 1),:) + minval; 267 | P_cond(:,find(c_cov == 0)) = P_cond(:,find(c_cov == 0)) - minval; 268 | 269 | stepnum = 4; 270 | 271 | function cnum = min_line_cover(Edge) 272 | 273 | % Step 2 274 | [r_cov,c_cov,M,stepnum] = step2(Edge); 275 | % Step 3 276 | [c_cov,stepnum] = step3(M,length(Edge)); 277 | % Step 4 278 | [M,r_cov,c_cov,Z_r,Z_c,stepnum] = step4(Edge,r_cov,c_cov,M); 279 | % Calculate the deficiency 280 | cnum = length(Edge)-sum(r_cov)-sum(c_cov); -------------------------------------------------------------------------------- /gitlocal/SSC/Misclassification.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function takes the groups resulted from spectral clutsering and the 3 | % ground truth to compute the misclassification rate. 4 | % groups: [grp1,grp2,grp3] for three different forms of Spectral Clustering 5 | % s: ground truth vector 6 | % Missrate: 3x1 vector with misclassification rates of three forms of 7 | % spectral clustering 8 | %-------------------------------------------------------------------------- 9 | % Copyright @ Ehsan Elhamifar, 2012 10 | %-------------------------------------------------------------------------- 11 | 12 | 13 | function Missrate = Misclassification(groups, gt) 14 | 15 | % n = max(s); 16 | % for i = 1:size(groups,2) 17 | % Missrate(i,1) = missclassGroups( groups(:,i),s,n ) ./ length(s); 18 | % end 19 | 20 | K = max(gt); 21 | M = zeros(K, K); 22 | for i=1:K 23 | idx = (groups == i); 24 | 25 | for j=1:K 26 | M(i, j) = sum(gt(idx) ~= j); 27 | end 28 | end 29 | 30 | [~, cost] = Hungarian(M); 31 | 32 | Missrate = cost / length(gt); -------------------------------------------------------------------------------- /gitlocal/SSC/SSC.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This is the function to call the sparse optimization program, to call the 3 | % spectral clustering algorithm and to compute the clustering error. 4 | % r = projection dimension, if r = 0, then no projection 5 | % affine = use the affine constraint if true 6 | % s = clustering ground-truth 7 | % missrate = clustering error 8 | % CMat = coefficient matrix obtained by SSC 9 | %-------------------------------------------------------------------------- 10 | % Copyright @ Ehsan Elhamifar, 2012 11 | %-------------------------------------------------------------------------- 12 | 13 | function [missrate,CMat] = SSC(X,r,affine,alpha,outlier,rho,s) 14 | 15 | if (nargin < 6) 16 | rho = 1; 17 | end 18 | if (nargin < 5) 19 | outlier = false; 20 | end 21 | if (nargin < 4) 22 | alpha = 20; 23 | end 24 | if (nargin < 3) 25 | affine = false; 26 | end 27 | if (nargin < 2) 28 | r = 0; 29 | end 30 | 31 | n = max(s); 32 | Xp = DataProjection(X,r); 33 | 34 | if (~outlier) 35 | CMat = admmLasso_mat_func(Xp,affine,alpha); 36 | C = CMat; 37 | else 38 | CMat = admmOutlier_mat_func(Xp,affine,alpha); 39 | N = size(Xp,2); 40 | C = CMat(1:N,:); 41 | end 42 | 43 | %CKSym = BuildAdjacency(thrC(C,rho)); % remove the post-processing for fair comparison 44 | CKSym = BuildAdjacency(C); 45 | grps = SpectralClustering(CKSym,n); 46 | missrate = Misclassification(grps,s); -------------------------------------------------------------------------------- /gitlocal/SSC/SpectralClustering.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function takes an adjacency matrix of a graph and computes the 3 | % clustering of the nodes using the spectral clustering algorithm of 4 | % Ng, Jordan and Weiss. 5 | % CMat: NxN adjacency matrix 6 | % n: number of groups for clustering 7 | % groups: N-dimensional vector containing the memberships of the N points 8 | % to the n groups obtained by spectral clustering 9 | %-------------------------------------------------------------------------- 10 | % Copyright @ Ehsan Elhamifar, 2012 11 | %-------------------------------------------------------------------------- 12 | 13 | function groups = SpectralClustering(CKSym,n) 14 | 15 | warning off; 16 | N = size(CKSym,1); 17 | MAXiter = 1000; % Maximum number of iterations for KMeans 18 | REPlic = 20; % Number of replications for KMeans 19 | 20 | % Normalized spectral clustering according to Ng & Jordan & Weiss 21 | % using Normalized Symmetric Laplacian L = I - D^{-1/2} W D^{-1/2} 22 | 23 | DN = diag( 1./sqrt(sum(CKSym)+eps) ); 24 | LapN = speye(N) - DN * CKSym * DN; 25 | [uN,sN,vN] = svd(LapN); 26 | kerN = vN(:,N-n+1:N); 27 | for i = 1:N 28 | kerNS(i,:) = kerN(i,:) ./ norm(kerN(i,:)+eps); 29 | end 30 | 31 | %options = statset('UseParallel', 'always'); 32 | %obj = parpool; 33 | %matlabpool open; 34 | groups = kmeans(kerNS,n,'maxiter',MAXiter, 'replicates',REPlic,'EmptyAction','singleton'); 35 | %matlabpool close; 36 | %delete(obj); -------------------------------------------------------------------------------- /gitlocal/SSC/admmLasso_mat_func.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function takes a DxN matrix of N data points in a D-dimensional 3 | % space and returns a NxN coefficient matrix of the sparse representation 4 | % of each data point in terms of the rest of the points 5 | % Y: DxN data matrix 6 | % affine: if true then enforce the affine constraint 7 | % thr1: stopping threshold for the coefficient error ||Z-C|| 8 | % thr2: stopping threshold for the linear system error ||Y-YZ|| 9 | % maxIter: maximum number of iterations of ADMM 10 | % C2: NxN sparse coefficient matrix 11 | %-------------------------------------------------------------------------- 12 | % Copyright @ Ehsan Elhamifar, 2012 13 | %-------------------------------------------------------------------------- 14 | 15 | function C2 = admmLasso_mat_func(Y,affine,alpha,thr,maxIter) 16 | 17 | if (nargin < 2) 18 | % default subspaces are linear 19 | affine = false; 20 | end 21 | if (nargin < 3) 22 | % default regularizarion parameters 23 | alpha = 800; 24 | end 25 | if (nargin < 4) 26 | % default coefficient error threshold to stop ADMM 27 | % default linear system error threshold to stop ADMM 28 | thr = 2*10^-4; 29 | end 30 | if (nargin < 5) 31 | % default maximum number of iterations of ADMM 32 | maxIter = 200; 33 | end 34 | 35 | if (length(alpha) == 1) 36 | alpha1 = alpha(1); 37 | alpha2 = alpha(1); 38 | elseif (length(alpha) == 2) 39 | alpha1 = alpha(1); 40 | alpha2 = alpha(2); 41 | end 42 | 43 | if (length(thr) == 1) 44 | thr1 = thr(1); 45 | thr2 = thr(1); 46 | elseif (length(thr) == 2) 47 | thr1 = thr(1); 48 | thr2 = thr(2); 49 | end 50 | 51 | N = size(Y,2); 52 | 53 | % setting penalty parameters for the ADMM 54 | mu1 = alpha1 * 1/computeLambda_mat(Y); 55 | mu2 = alpha2 * 1; 56 | 57 | if (~affine) 58 | % initialization 59 | A = inv(mu1*(Y'*Y)+mu2*eye(N)); 60 | C1 = zeros(N,N); 61 | Lambda2 = zeros(N,N); 62 | err1 = 10*thr1; err2 = 10*thr2; 63 | i = 1; 64 | % ADMM iterations 65 | while ( err1(i) > thr1 && i < maxIter ) 66 | % updating Z 67 | Z = A * (mu1*(Y'*Y)+mu2*(C1-Lambda2/mu2)); 68 | Z = Z - diag(diag(Z)); 69 | % updating C 70 | C2 = max(0,(abs(Z+Lambda2/mu2) - 1/mu2*ones(N))) .* sign(Z+Lambda2/mu2); 71 | C2 = C2 - diag(diag(C2)); 72 | % updating Lagrange multipliers 73 | Lambda2 = Lambda2 + mu2 * (Z - C2); 74 | % computing errors 75 | err1(i+1) = errorCoef(Z,C2); 76 | err2(i+1) = errorLinSys(Y,Z); 77 | % 78 | C1 = C2; 79 | i = i + 1; 80 | end 81 | fprintf('err1: %2.4f, err2: %2.4f, iter: %3.0f \n',err1(end),err2(end),i); 82 | else 83 | % initialization 84 | A = inv(mu1*(Y'*Y)+mu2*eye(N)+mu2*ones(N,N)); 85 | C1 = zeros(N,N); 86 | Lambda2 = zeros(N,N); 87 | lambda3 = zeros(1,N); 88 | err1 = 10*thr1; err2 = 10*thr2; err3 = 10*thr1; 89 | i = 1; 90 | % ADMM iterations 91 | while ( (err1(i) > thr1 || err3(i) > thr1) && i < maxIter ) 92 | % updating Z 93 | Z = A * (mu1*(Y'*Y)+mu2*(C1-Lambda2/mu2)+mu2*ones(N,1)*(ones(1,N)-lambda3/mu2)); 94 | Z = Z - diag(diag(Z)); 95 | % updating C 96 | C2 = max(0,(abs(Z+Lambda2/mu2) - 1/mu2*ones(N))) .* sign(Z+Lambda2/mu2); 97 | C2 = C2 - diag(diag(C2)); 98 | % updating Lagrange multipliers 99 | Lambda2 = Lambda2 + mu2 * (Z - C2); 100 | lambda3 = lambda3 + mu2 * (ones(1,N)*Z - ones(1,N)); 101 | % computing errors 102 | err1(i+1) = errorCoef(Z,C2); 103 | err2(i+1) = errorLinSys(Y,Z); 104 | err3(i+1) = errorCoef(ones(1,N)*Z,ones(1,N)); 105 | % 106 | C1 = C2; 107 | i = i + 1; 108 | end 109 | fprintf('err1: %2.4f, err2: %2.4f, err3: %2.4f, iter: %3.0f \n',err1(end),err2(end),err3(end),i); 110 | end -------------------------------------------------------------------------------- /gitlocal/SSC/admmOutlier_mat_func.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function takes a DxN matrix of N data points in a D-dimensional 3 | % space and returns a NxN coefficient matrix of the sparse representation 4 | % of each data point in terms of the rest of the points 5 | % Y: DxN data matrix 6 | % affine: true if enforcing the affine constraint, false otherwise 7 | % thr1: stopping threshold for the coefficient error ||Z-C|| 8 | % thr2: stopping threshold for the linear system error ||Y-YZ|| 9 | % maxIter: maximum number of iterations of ADMM 10 | % C2: NxN sparse coefficient matrix 11 | %-------------------------------------------------------------------------- 12 | % Copyright @ Ehsan Elhamifar, 2012 13 | %-------------------------------------------------------------------------- 14 | 15 | function C2 = admmOutlier_mat_func(Y,affine,alpha,thr,maxIter) 16 | 17 | if (nargin < 2) 18 | % default subspaces are linear 19 | affine = false; 20 | end 21 | if (nargin < 3) 22 | % default regularizarion parameters 23 | alpha = 20; 24 | end 25 | if (nargin < 4) 26 | % default coefficient error threshold to stop ALM 27 | % default linear system error threshold to stop ALM 28 | thr = 2*10^-4; 29 | end 30 | if (nargin < 5) 31 | % default maximum number of iterations of ALM 32 | maxIter = 150; 33 | end 34 | 35 | if (length(alpha) == 1) 36 | alpha1 = alpha(1); 37 | alpha2 = alpha(1); 38 | alpha3 = alpha(1); 39 | elseif (length(alpha) == 2) 40 | alpha1 = alpha(1); 41 | alpha2 = alpha(2); 42 | alpha3 = alpha(2); 43 | elseif (length(alpha) == 3) 44 | alpha1 = alpha(1); 45 | alpha2 = alpha(2); 46 | alpha3 = alpha(3); 47 | end 48 | 49 | if (length(thr) == 1) 50 | thr1 = thr(1); 51 | thr2 = thr(1); 52 | elseif (length(thr) == 2) 53 | thr1 = thr(1); 54 | thr2 = thr(2); 55 | end 56 | 57 | [D,N] = size(Y); 58 | 59 | gamma = alpha3 / norm(Y,1); 60 | P = [Y eye(D)/gamma]; 61 | 62 | % setting penalty parameters for the ADMM 63 | mu1 = alpha1 * 1/computeLambda_mat(Y,P); 64 | mu2 = alpha2 * 1; 65 | 66 | if (~affine) 67 | % initialization 68 | A = inv(mu1*(P'*P)+mu2*eye(N+D)); 69 | C1 = zeros(N+D,N); 70 | Lambda1 = zeros(D,N); 71 | Lambda2 = zeros(N+D,N); 72 | err1 = 10*thr1; err2 = 10*thr2; 73 | i = 1; 74 | % ADMM iterations 75 | while ( (err1(i) > thr1 || err2(i) > thr2) && i < maxIter ) 76 | % updating Z 77 | Z = A * (mu1*P'*(Y+Lambda1/mu1)+mu2*(C1-Lambda2/mu2)); 78 | Z(1:N,:) = Z(1:N,:) - diag(diag(Z(1:N,:))); 79 | % updating C 80 | C2 = max(0,(abs(Z+Lambda2/mu2) - 1/mu2*ones(N+D,N))) .* sign(Z+Lambda2/mu2); 81 | C2(1:N,:) = C2(1:N,:) - diag(diag(C2(1:N,:))); 82 | % updating Lagrange multipliers 83 | Lambda1 = Lambda1 + mu1 * (Y - P * Z); 84 | Lambda2 = Lambda2 + mu2 * (Z - C2); 85 | % computing errors 86 | err1(i+1) = errorCoef(Z,C2); 87 | err2(i+1) = errorLinSys(P,Z); 88 | % 89 | C1 = C2; 90 | i = i + 1; 91 | end 92 | fprintf('err1: %2.4f, err2: %2.4f, iter: %3.0f \n',err1(end),err2(end),i); 93 | else 94 | % initialization 95 | delta = [ones(N,1);zeros(D,1)]; 96 | A = inv(mu1*(P'*P)+mu2*eye(N+D)+mu2*(delta*delta')); 97 | C1 = zeros(N+D,N); 98 | Lambda1 = zeros(D,N); 99 | Lambda2 = zeros(N+D,N); 100 | lambda3 = zeros(1,N); 101 | err1 = 10*thr1; err2 = 10*thr2; err3 = 10*thr1; 102 | i = 1; 103 | % ADMM iterations 104 | while ( (err1(i) > thr1 || err2(i) > thr2 || err3(i) > thr1) && i < maxIter ) 105 | % updating Z 106 | Z = A * (mu1*P'*(Y+Lambda1/mu1)+mu2*(C1-Lambda2/mu2)+mu2*delta*(ones(1,N)-lambda3/mu2)); 107 | Z(1:N,:) = Z(1:N,:) - diag(diag(Z(1:N,:))); 108 | % updating C 109 | C2 = max(0,(abs(Z+Lambda2/mu2) - 1/mu2*ones(N+D,N))) .* sign(Z+Lambda2/mu2); 110 | C2(1:N,:) = C2(1:N,:) - diag(diag(C2(1:N,:))); 111 | % updating Lagrange multipliers 112 | Lambda1 = Lambda1 + mu1 * (Y - P * Z); 113 | Lambda2 = Lambda2 + mu2 * (Z - C2); 114 | lambda3 = lambda3 + mu2 * (delta'*Z - ones(1,N)); 115 | % computing errors 116 | err1(i+1) = errorCoef(Z,C2); 117 | err2(i+1) = errorLinSys(P,Z); 118 | err3(i+1) = errorCoef(delta'*Z,ones(1,N)); 119 | % 120 | C1 = C2; 121 | i = i + 1; 122 | end 123 | fprintf('err1: %2.4f, err2: %2.4f, err3: %2.4f, iter: %3.0f \n',err1(end),err2(end),err3(end),i); 124 | end -------------------------------------------------------------------------------- /gitlocal/SSC/computeLambda_mat.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function takes a DxN matrix of N data points in a D-dimensional 3 | % space and returns the regularization constant of the L1 norm 4 | % Y: DxN data matrix 5 | % lambda: regularization parameter for lambda*||C||_1 + 0.5 ||Y-YC||_F^2 6 | %-------------------------------------------------------------------------- 7 | % Copyright @ Ehsan Elhamifar, 2012 8 | %-------------------------------------------------------------------------- 9 | 10 | function lambda = computeLambda_mat(Y,P) 11 | 12 | if (nargin < 2) 13 | P = Y; 14 | end 15 | 16 | N = size(Y,2); 17 | T = P' * Y; 18 | T(1:N,:) = T(1:N,:) - diag(diag(T(1:N,:))); 19 | T = abs(T); 20 | lambda = min(max(T,[],1)); 21 | -------------------------------------------------------------------------------- /gitlocal/SSC/errorCoef.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function computes the maximum error between elements of two 3 | % coefficient matrices 4 | % C: NxN coefficient matrix 5 | % Z: NxN coefficient matrix 6 | % err: infinite norm error between vectorized C and Z 7 | %-------------------------------------------------------------------------- 8 | % Copyright @ Ehsan Elhamifar, 2012 9 | %-------------------------------------------------------------------------- 10 | 11 | function err = errorCoef(Z,C) 12 | 13 | err = max(max( abs(Z-C) )); 14 | %err = norm(Z-C,'fro'); -------------------------------------------------------------------------------- /gitlocal/SSC/errorLinSys.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function computes the maximum L2-norm error among the columns of the 3 | % residual of a linear system 4 | % Y: DxN data matrix of N data point in a D-dimensional space 5 | % Z: NxN sparse coefficient matrix 6 | % err: maximum L2-norm of the columns of Y-YZ 7 | %-------------------------------------------------------------------------- 8 | % Copyright @ Ehsan Elhamifar, 2012 9 | %-------------------------------------------------------------------------- 10 | 11 | function err = errorLinSys(P,Z) 12 | 13 | [R,N] = size(Z); 14 | if (R > N) 15 | E = P(:,N+1:end) * Z(N+1:end,:); 16 | Y = P(:,1:N); 17 | Y0 = Y - E; 18 | C = Z(1:N,:); 19 | else 20 | Y = P; 21 | Y0 = P; 22 | C = Z; 23 | end 24 | 25 | [Yn,n] = matrixNormalize(Y0); 26 | M = repmat(n,size(Y,1),1); 27 | S = Yn - Y * C ./ M; 28 | err = sqrt( max( sum( S.^2,1 ) ) ); -------------------------------------------------------------------------------- /gitlocal/SSC/matrixNormalize.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This function normalizes the columns of a given matrix 3 | % Y: DxN data matrix 4 | % Yn: DxN data matrix whose columns have unit Euclidean norm 5 | % n: N-dimensional vector of the norms of the columns of Y 6 | %-------------------------------------------------------------------------- 7 | % Copyright @ Ehsan Elhamifar, 2012 8 | %-------------------------------------------------------------------------- 9 | 10 | function [Yn,n] = matrixNormalize(Y) 11 | 12 | for i = 1:size(Y,2) 13 | n(i) = norm(Y(:,i)); 14 | Yn(:,i) = Y(:,i) ./ n(i); 15 | end -------------------------------------------------------------------------------- /gitlocal/SSC/missclassGroups.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % [miss,index] = missclass(Segmentation,RefSegmentation,ngroups) 3 | % Computes the number of missclassified points in the vector Segmentation. 4 | % Segmentation: 1 by sum(npoints) or sum(ngroups) by 1 vector containing 5 | % the label for each group, ranging from 1 to n 6 | % npoints: 1 by ngroups or ngroups by 1 vector containing the number of 7 | % points in each group. 8 | % ngroups: number of groups 9 | %-------------------------------------------------------------------------- 10 | % Copyright @ Ehsan Elhamifar, 2012 11 | %-------------------------------------------------------------------------- 12 | 13 | 14 | function [miss,index] = missclassGroups(Segmentation,RefSegmentation,ngroups) 15 | 16 | Permutations = perms(1:ngroups); 17 | if(size(Segmentation,2)==1) 18 | Segmentation=Segmentation'; 19 | end 20 | miss = zeros(size(Permutations,1),size(Segmentation,1)); 21 | for k=1:size(Segmentation,1) 22 | for j=1:size(Permutations,1) 23 | miss(j,k) = sum(Segmentation(k,:)~=Permutations(j,RefSegmentation)); 24 | end 25 | end 26 | 27 | [miss,temp] = min(miss,[],1); 28 | index = Permutations(temp,:); 29 | -------------------------------------------------------------------------------- /gitlocal/SSC/readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junwang929/subspace-clustering/48c68d32133ceb92b90454de517c3a3d3368539d/gitlocal/SSC/readme.pdf -------------------------------------------------------------------------------- /gitlocal/SSC/readme.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf510 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \margl1440\margr1440\vieww17620\viewh12960\viewkind0 5 | \deftab720 6 | \pard\pardeftab720 7 | 8 | \f0\fs26 \cf0 ---------------------------------------------------------------------------------------------------------------------\ 9 | Copyright @ Ehsan Elhamifar, 2012\ 10 | \ 11 | ---------------------------------------------------------------------------------------------------------------------\ 12 | To run the Sparse Subspace Clustering (SSC) algorithm\ 13 | \ 14 | for motion segmentation on the Hopkins 155 dataset, see the following m-file: run_SSC_MS.m. \ 15 | for face clustering on the Extended Yale B dataset, see the following m-file: run_SSC_Faces.m. \ 16 | \ 17 | ---------------------------------------------------------------------------------------------------------------------\ 18 | Terms of use: \ 19 | The code is provided for research purposes only and without any warranty. Any commercial use is prohibited. \ 20 | \ 21 | When using the code in your research work, you should cite the following paper:\ 22 | \ 23 | Sparse Subspace Clustering: Algorithm, Theory, and Applications\ 24 | E. Elhamifar and R. Vidal, \ 25 | Submitted to IEEE Trans. on PAMI, 2011.\ 26 | Available: {\field{\*\fldinst{HYPERLINK "http://arxiv.org/abs/1203.1005"}}{\fldrslt http://arxiv.org/abs/1203.1005}}\ 27 | \ 28 | ---------------------------------------------------------------------------------------------------------------------\ 29 | Please contact Ehsan Elhamifar (ehsan [At] cis [Dot] jhu [Dot] edu) for questions about the code.} -------------------------------------------------------------------------------- /gitlocal/SSC/run_SSC_Faces.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This is the main function to run the SSC algorithm for the face 3 | % clustering problem on the Extended Yale B dataset. 4 | % avgmissrate: the n-th element contains the average clustering error for 5 | % n subjects 6 | % medmissrate: the n-th element contains the median clustering error for 7 | % n subjects 8 | % nSet: the set of the different number of subjects to run the algorithm on 9 | %-------------------------------------------------------------------------- 10 | % Copyright @ Ehsan Elhamifar, 2012 11 | %-------------------------------------------------------------------------- 12 | 13 | clear all, close all 14 | 15 | load YaleBCrop025.mat 16 | 17 | alpha = 20; 18 | 19 | nSet = [2 3 5 8 10]; 20 | for i = 1:length(nSet) 21 | n = nSet(i); 22 | idx = Ind{n}; 23 | for j = 1:size(idx,1) 24 | X = []; 25 | for p = 1:n 26 | X = [X Y(:,:,idx(j,p))]; 27 | end 28 | [D,N] = size(X); 29 | 30 | r = 0; affine = false; outlier = true; rho = 1; 31 | [missrate,C] = SSC(X,r,affine,alpha,outlier,rho,s{n}); 32 | missrateTot{n}(j) = missrate; 33 | 34 | save SSC_Faces.mat missrateTot alpha 35 | end 36 | avgmissrate(n) = mean(missrateTot{n}); 37 | medmissrate(n) = median(missrateTot{n}); 38 | 39 | save SSC_Faces.mat missrateTot avgmissrate medmissrate alpha 40 | end 41 | 42 | save SSC_Faces.mat missrateTot avgmissrate medmissrate alpha -------------------------------------------------------------------------------- /gitlocal/SSC/run_SSC_MS.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % This is the main function to run the SSC algorithm for the motion 3 | % segmentation problem on the Hopkins 155 dataset. 4 | % 5 | % cd to the main folder containing the Hopkins 155 sequences 6 | % add the path to the folder "SSC_motion_face" containing these m-files 7 | % 8 | % avgmissrate1: the n-th element contains the average clustering error for 9 | % sequences with n motions (using 2F-dimensional data) 10 | % avgmissrate2: the n-th element contains the average clustering error for 11 | % sequences with n motions (using 4n-dimensional data) 12 | % medmissrate1: the n-th element contains the median clustering error for 13 | % sequences with n motions (using 2F-dimensional data) 14 | % medmissrate2: the n-th element contains the median clustering error for 15 | % sequences with n motions (using 4n-dimensional data) 16 | %-------------------------------------------------------------------------- 17 | % Copyright @ Ehsan Elhamifar, 2012 18 | %-------------------------------------------------------------------------- 19 | 20 | clc, clear all, close all 21 | 22 | cd '/Users/ehsanelhamifar/Documents/MatlabCode/Hopkins155/'; 23 | addpath '/Users/ehsanelhamifar/Documents/MatlabCode/SSC_motion_face/'; 24 | 25 | alpha = 800; 26 | 27 | maxNumGroup = 5; 28 | for i = 1:maxNumGroup 29 | num(i) = 0; 30 | end 31 | 32 | d = dir; 33 | for i = 1:length(d) 34 | if ( (d(i).isdir == 1) && ~strcmp(d(i).name,'.') && ~strcmp(d(i).name,'..') ) 35 | filepath = d(i).name; 36 | eval(['cd ' filepath]); 37 | 38 | f = dir; 39 | foundValidData = false; 40 | for j = 1:length(f) 41 | if ( ~isempty(strfind(f(j).name,'_truth.mat')) ) 42 | ind = j; 43 | foundValidData = true; 44 | break 45 | end 46 | end 47 | eval(['load ' f(ind).name]); 48 | cd .. 49 | 50 | if (foundValidData) 51 | n = max(s); 52 | N = size(x,2); 53 | F = size(x,3); 54 | D = 2*F; 55 | X = reshape(permute(x(1:2,:,:),[1 3 2]),D,N); 56 | 57 | r = 0; affine = true; outlier = false; rho = 0.7; 58 | [missrate1,C1] = SSC(X,r,affine,alpha,outlier,rho,s); 59 | 60 | r = 4*n; affine = true; outlier = false; rho = 0.7; 61 | [missrate2,C2] = SSC(X,r,affine,alpha,outlier,rho,s); 62 | 63 | num(n) = num(n) + 1; 64 | missrateTot1{n}(num(n)) = missrate1; 65 | missrateTot2{n}(num(n)) = missrate2; 66 | 67 | eval(['cd ' filepath]); 68 | save SSC_MS.mat missrate1 missrate2 C1 C2 alpha 69 | cd .. 70 | end 71 | end 72 | end 73 | 74 | L = [2 3]; 75 | for i = 1:length(L) 76 | j = L(i); 77 | avgmissrate1(j) = mean(missrateTot1{j}); 78 | medmissrate1(j) = median(missrateTot1{j}); 79 | avgmissrate2(j) = mean(missrateTot2{j}); 80 | medmissrate2(j) = median(missrateTot2{j}); 81 | end 82 | save SSC_MS.mat missrateTot1 avgmissrate1 medmissrate1 missrateTot2 avgmissrate2 medmissrate2 alpha -------------------------------------------------------------------------------- /gitlocal/SSC/thrC.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | % Copyright @ Ehsan Elhamifar, 2012 3 | %-------------------------------------------------------------------------- 4 | 5 | function Cp = thrC(C,ro) 6 | 7 | if (nargin < 2) 8 | ro = 1; 9 | end 10 | 11 | if (ro < 1) 12 | N = size(C,2); 13 | Cp = zeros(N,N); 14 | [S,Ind] = sort(abs(C),1,'descend'); 15 | for i = 1:N 16 | cL1 = sum(S(:,i)); 17 | stop = false; 18 | cSum = 0; t = 0; 19 | while (~stop) 20 | t = t + 1; 21 | cSum = cSum + S(t,i); 22 | if ( cSum >= ro*cL1 ) 23 | stop = true; 24 | Cp(Ind(1:t,i),i) = C(Ind(1:t,i),i); 25 | end 26 | end 27 | end 28 | else 29 | Cp = C; 30 | end -------------------------------------------------------------------------------- /gitlocal/SVHN.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a71da5b4d0e0bfaf8a58271117f9a780e9d97be81e6bb60c9e44e07a569a95d2 3 | size 639970936 4 | -------------------------------------------------------------------------------- /gitlocal/clusterings/F.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junwang929/subspace-clustering/48c68d32133ceb92b90454de517c3a3d3368539d/gitlocal/clusterings/F.m -------------------------------------------------------------------------------- /gitlocal/clusterings/NMI.m: -------------------------------------------------------------------------------- 1 | function acc=NMI(inx,gnd) 2 | if size(inx,2)==1 3 | inx = inx'; 4 | end 5 | if size(gnd,2)==1 6 | gnd = gnd'; 7 | end 8 | assert(size(inx,2)==size(gnd,2),'Different Size!!'); 9 | assert(min(inx)>=0,'InxMin is unexpected'); 10 | assert(min(gnd)>=0,'GndMin is unexpected'); 11 | if min(inx)==0 12 | inx = inx+1; 13 | end 14 | if min(gnd)==0 15 | gnd = gnd+1; 16 | end 17 | k = max(max(inx),max(gnd)); 18 | N = size(inx,2); 19 | tempmatrix = zeros(k); 20 | for i=1:size(inx,2) 21 | tempmatrix(inx(i),gnd(i))= tempmatrix(inx(i),gnd(i))+1; 22 | end 23 | %% count the numbers in each inx-cluster or gnd-cluster 24 | numinx = zeros(1,max(inx)); 25 | numgnd = zeros(1,max(gnd)); 26 | for i=1:size(inx,2) 27 | numinx(inx(i))=numinx(inx(i))+1; 28 | numgnd(gnd(i))=numgnd(gnd(i))+1; 29 | end 30 | numinx 31 | numgnd 32 | %% compute NMI 33 | acc =0; 34 | for j = 1:size(numinx,2) 35 | for k =1:size(numgnd,2) 36 | if tempmatrix(j,k)~=0 && numinx(j)~=0 && numgnd(k)~=0 37 | acc = acc+tempmatrix(j,k)*(1/N)*log(N*tempmatrix(j,k)/(numinx(j)*numgnd(k))); 38 | end 39 | end 40 | end 41 | acc = acc*2/(H(numinx,N)+H(numgnd,N)); 42 | end 43 | function Hacc = H(numarray,N) 44 | Hacc = 0; 45 | for i =1:size(numarray,2) 46 | if numarray(i)~=0 47 | Hacc = Hacc- numarray(i)*(1/N)*log(numarray(i)*(1/N)); 48 | end 49 | end 50 | end 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /gitlocal/clusterings/bestMap.m: -------------------------------------------------------------------------------- 1 | function [newL2] = bestMap(L1,L2) 2 | %bestmap: permute labels of L2 to match L1 as good as possible 3 | % [newL2] = bestMap(L1,L2); 4 | % 5 | % version 2.0 --May/2007 6 | % version 1.0 --November/2003 7 | % 8 | % Written by Deng Cai (dengcai AT gmail.com) 9 | 10 | 11 | %=========== 12 | 13 | L1 = L1(:); 14 | L2 = L2(:); 15 | if size(L1) ~= size(L2) 16 | error('size(L1) must == size(L2)'); 17 | end 18 | 19 | Label1 = unique(L1); 20 | nClass1 = length(Label1); 21 | Label2 = unique(L2); 22 | nClass2 = length(Label2); 23 | 24 | nClass = max(nClass1,nClass2); 25 | G = zeros(nClass); 26 | for i=1:nClass1 27 | for j=1:nClass2 28 | G(i,j) = length(find(L1 == Label1(i) & L2 == Label2(j))); 29 | end 30 | end 31 | 32 | [c,t] = hungarian(-G); 33 | newL2 = zeros(size(L2)); 34 | for i=1:nClass2 35 | newL2(L2 == Label2(i)) = Label1(c(i)); 36 | end 37 | -------------------------------------------------------------------------------- /gitlocal/clusterings/calnk.m: -------------------------------------------------------------------------------- 1 | function [nk] = calnk(my) 2 | %CALNK Summary of this function goes here 3 | % Detailed explanation goes here 4 | [m,n]= size(my); 5 | if m==1 6 | nn = n; 7 | else 8 | nn = m; 9 | end 10 | nk= 1; 11 | for i = 1:nn-1 12 | if my(i+1)~= my(i) 13 | nk = nk+1; 14 | end 15 | end 16 | 17 | 18 | end 19 | 20 | -------------------------------------------------------------------------------- /gitlocal/clusterings/calnumber.m: -------------------------------------------------------------------------------- 1 | function [ K ] = calnumber( label ) 2 | %CALNUMBER Summary of this function goes here 3 | % Detailed explanation goes here 4 | minlabel = min(label); 5 | maxlabel = max(label); 6 | K = 2; 7 | [m, n]= size(label); 8 | if m == 1 9 | nn=n; 10 | else 11 | nn=m; 12 | end 13 | for i = (minlabel+1):(maxlabel-1) 14 | for j = 1:nn 15 | if label(j) ==i 16 | K = K+1; 17 | break; 18 | end 19 | end 20 | end 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /gitlocal/clusterings/clustering.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junwang929/subspace-clustering/48c68d32133ceb92b90454de517c3a3d3368539d/gitlocal/clusterings/clustering.m -------------------------------------------------------------------------------- /gitlocal/clusterings/f_P.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junwang929/subspace-clustering/48c68d32133ceb92b90454de517c3a3d3368539d/gitlocal/clusterings/f_P.m -------------------------------------------------------------------------------- /gitlocal/clusterings/hungarian.m: -------------------------------------------------------------------------------- 1 | function [C,T]=hungarian(A) 2 | %HUNGARIAN Solve the Assignment problem using the Hungarian method. 3 | % 4 | %[C,T]=hungarian(A) 5 | %A - a square cost matrix. 6 | %C - the optimal assignment. 7 | %T - the cost of the optimal assignment. 8 | %s.t. T = trace(A(C,:)) is minimized over all possible assignments. 9 | 10 | % Adapted from the FORTRAN IV code in Carpaneto and Toth, "Algorithm 548: 11 | % Solution of the assignment problem [H]", ACM Transactions on 12 | % Mathematical Software, 6(1):104-111, 1980. 13 | 14 | % v1.0 96-06-14. Niclas Borlin, niclas@cs.umu.se. 15 | % Department of Computing Science, Ume? University, 16 | % Sweden. 17 | % All standard disclaimers apply. 18 | 19 | % A substantial effort was put into this code. If you use it for a 20 | % publication or otherwise, please include an acknowledgement or at least 21 | % notify me by email. /Niclas 22 | 23 | [m,n]=size(A); 24 | 25 | if (m~=n) 26 | error('HUNGARIAN: Cost matrix must be square!'); 27 | end 28 | 29 | % Save original cost matrix. 30 | orig=A; 31 | 32 | % Reduce matrix. 33 | A=hminired(A); 34 | 35 | % Do an initial assignment. 36 | [A,C,U]=hminiass(A); 37 | 38 | % Repeat while we have unassigned rows. 39 | while (U(n+1)) 40 | % Start with no path, no unchecked zeros, and no unexplored rows. 41 | LR=zeros(1,n); 42 | LC=zeros(1,n); 43 | CH=zeros(1,n); 44 | RH=[zeros(1,n) -1]; 45 | 46 | % No labelled columns. 47 | SLC=[]; 48 | 49 | % Start path in first unassigned row. 50 | r=U(n+1); 51 | % Mark row with end-of-path label. 52 | LR(r)=-1; 53 | % Insert row first in labelled row set. 54 | SLR=r; 55 | 56 | % Repeat until we manage to find an assignable zero. 57 | while (1) 58 | % If there are free zeros in row r 59 | if (A(r,n+1)~=0) 60 | % ...get column of first free zero. 61 | l=-A(r,n+1); 62 | 63 | % If there are more free zeros in row r and row r in not 64 | % yet marked as unexplored.. 65 | if (A(r,l)~=0 & RH(r)==0) 66 | % Insert row r first in unexplored list. 67 | RH(r)=RH(n+1); 68 | RH(n+1)=r; 69 | 70 | % Mark in which column the next unexplored zero in this row 71 | % is. 72 | CH(r)=-A(r,l); 73 | end 74 | else 75 | % If all rows are explored.. 76 | if (RH(n+1)<=0) 77 | % Reduce matrix. 78 | [A,CH,RH]=hmreduce(A,CH,RH,LC,LR,SLC,SLR); 79 | end 80 | 81 | % Re-start with first unexplored row. 82 | r=RH(n+1); 83 | % Get column of next free zero in row r. 84 | l=CH(r); 85 | % Advance "column of next free zero". 86 | CH(r)=-A(r,l); 87 | % If this zero is last in the list.. 88 | if (A(r,l)==0) 89 | % ...remove row r from unexplored list. 90 | RH(n+1)=RH(r); 91 | RH(r)=0; 92 | end 93 | end 94 | 95 | % While the column l is labelled, i.e. in path. 96 | while (LC(l)~=0) 97 | % If row r is explored.. 98 | if (RH(r)==0) 99 | % If all rows are explored.. 100 | if (RH(n+1)<=0) 101 | % Reduce cost matrix. 102 | [A,CH,RH]=hmreduce(A,CH,RH,LC,LR,SLC,SLR); 103 | end 104 | 105 | % Re-start with first unexplored row. 106 | r=RH(n+1); 107 | end 108 | 109 | % Get column of next free zero in row r. 110 | l=CH(r); 111 | 112 | % Advance "column of next free zero". 113 | CH(r)=-A(r,l); 114 | 115 | % If this zero is last in list.. 116 | if(A(r,l)==0) 117 | % ...remove row r from unexplored list. 118 | RH(n+1)=RH(r); 119 | RH(r)=0; 120 | end 121 | end 122 | 123 | % If the column found is unassigned.. 124 | if (C(l)==0) 125 | % Flip all zeros along the path in LR,LC. 126 | [A,C,U]=hmflip(A,C,LC,LR,U,l,r); 127 | % ...and exit to continue with next unassigned row. 128 | break; 129 | else 130 | % ...else add zero to path. 131 | 132 | % Label column l with row r. 133 | LC(l)=r; 134 | 135 | % Add l to the set of labelled columns. 136 | SLC=[SLC l]; 137 | 138 | % Continue with the row assigned to column l. 139 | r=C(l); 140 | 141 | % Label row r with column l. 142 | LR(r)=l; 143 | 144 | % Add r to the set of labelled rows. 145 | SLR=[SLR r]; 146 | end 147 | end 148 | end 149 | 150 | % Calculate the total cost. 151 | T=sum(orig(logical(sparse(C,1:size(orig,2),1)))); 152 | 153 | 154 | function A=hminired(A) 155 | %HMINIRED Initial reduction of cost matrix for the Hungarian method. 156 | % 157 | %B=assredin(A) 158 | %A - the unreduced cost matris. 159 | %B - the reduced cost matrix with linked zeros in each row. 160 | 161 | % v1.0 96-06-13. Niclas Borlin, niclas@cs.umu.se. 162 | 163 | [m,n]=size(A); 164 | 165 | % Subtract column-minimum values from each column. 166 | colMin=min(A); 167 | A=A-colMin(ones(n,1),:); 168 | 169 | % Subtract row-minimum values from each row. 170 | rowMin=min(A')'; 171 | A=A-rowMin(:,ones(1,n)); 172 | 173 | % Get positions of all zeros. 174 | [i,j]=find(A==0); 175 | 176 | % Extend A to give room for row zero list header column. 177 | A(1,n+1)=0; 178 | for k=1:n 179 | % Get all column in this row. 180 | cols=j(k==i)'; 181 | % Insert pointers in matrix. 182 | A(k,[n+1 cols])=[-cols 0]; 183 | end 184 | 185 | 186 | function [A,C,U]=hminiass(A) 187 | %HMINIASS Initial assignment of the Hungarian method. 188 | % 189 | %[B,C,U]=hminiass(A) 190 | %A - the reduced cost matrix. 191 | %B - the reduced cost matrix, with assigned zeros removed from lists. 192 | %C - a vector. C(J)=I means row I is assigned to column J, 193 | % i.e. there is an assigned zero in position I,J. 194 | %U - a vector with a linked list of unassigned rows. 195 | 196 | % v1.0 96-06-14. Niclas Borlin, niclas@cs.umu.se. 197 | 198 | [n,np1]=size(A); 199 | 200 | % Initalize return vectors. 201 | C=zeros(1,n); 202 | U=zeros(1,n+1); 203 | 204 | % Initialize last/next zero "pointers". 205 | LZ=zeros(1,n); 206 | NZ=zeros(1,n); 207 | 208 | for i=1:n 209 | % Set j to first unassigned zero in row i. 210 | lj=n+1; 211 | j=-A(i,lj); 212 | 213 | % Repeat until we have no more zeros (j==0) or we find a zero 214 | % in an unassigned column (c(j)==0). 215 | 216 | while (C(j)~=0) 217 | % Advance lj and j in zero list. 218 | lj=j; 219 | j=-A(i,lj); 220 | 221 | % Stop if we hit end of list. 222 | if (j==0) 223 | break; 224 | end 225 | end 226 | 227 | if (j~=0) 228 | % We found a zero in an unassigned column. 229 | 230 | % Assign row i to column j. 231 | C(j)=i; 232 | 233 | % Remove A(i,j) from unassigned zero list. 234 | A(i,lj)=A(i,j); 235 | 236 | % Update next/last unassigned zero pointers. 237 | NZ(i)=-A(i,j); 238 | LZ(i)=lj; 239 | 240 | % Indicate A(i,j) is an assigned zero. 241 | A(i,j)=0; 242 | else 243 | % We found no zero in an unassigned column. 244 | 245 | % Check all zeros in this row. 246 | 247 | lj=n+1; 248 | j=-A(i,lj); 249 | 250 | % Check all zeros in this row for a suitable zero in another row. 251 | while (j~=0) 252 | % Check the in the row assigned to this column. 253 | r=C(j); 254 | 255 | % Pick up last/next pointers. 256 | lm=LZ(r); 257 | m=NZ(r); 258 | 259 | % Check all unchecked zeros in free list of this row. 260 | while (m~=0) 261 | % Stop if we find an unassigned column. 262 | if (C(m)==0) 263 | break; 264 | end 265 | 266 | % Advance one step in list. 267 | lm=m; 268 | m=-A(r,lm); 269 | end 270 | 271 | if (m==0) 272 | % We failed on row r. Continue with next zero on row i. 273 | lj=j; 274 | j=-A(i,lj); 275 | else 276 | % We found a zero in an unassigned column. 277 | 278 | % Replace zero at (r,m) in unassigned list with zero at (r,j) 279 | A(r,lm)=-j; 280 | A(r,j)=A(r,m); 281 | 282 | % Update last/next pointers in row r. 283 | NZ(r)=-A(r,m); 284 | LZ(r)=j; 285 | 286 | % Mark A(r,m) as an assigned zero in the matrix . . . 287 | A(r,m)=0; 288 | 289 | % ...and in the assignment vector. 290 | C(m)=r; 291 | 292 | % Remove A(i,j) from unassigned list. 293 | A(i,lj)=A(i,j); 294 | 295 | % Update last/next pointers in row r. 296 | NZ(i)=-A(i,j); 297 | LZ(i)=lj; 298 | 299 | % Mark A(r,m) as an assigned zero in the matrix . . . 300 | A(i,j)=0; 301 | 302 | % ...and in the assignment vector. 303 | C(j)=i; 304 | 305 | % Stop search. 306 | break; 307 | end 308 | end 309 | end 310 | end 311 | 312 | % Create vector with list of unassigned rows. 313 | 314 | % Mark all rows have assignment. 315 | r=zeros(1,n); 316 | rows=C(C~=0); 317 | r(rows)=rows; 318 | empty=find(r==0); 319 | 320 | % Create vector with linked list of unassigned rows. 321 | U=zeros(1,n+1); 322 | U([n+1 empty])=[empty 0]; 323 | 324 | 325 | function [A,C,U]=hmflip(A,C,LC,LR,U,l,r) 326 | %HMFLIP Flip assignment state of all zeros along a path. 327 | % 328 | %[A,C,U]=hmflip(A,C,LC,LR,U,l,r) 329 | %Input: 330 | %A - the cost matrix. 331 | %C - the assignment vector. 332 | %LC - the column label vector. 333 | %LR - the row label vector. 334 | %U - the 335 | %r,l - position of last zero in path. 336 | %Output: 337 | %A - updated cost matrix. 338 | %C - updated assignment vector. 339 | %U - updated unassigned row list vector. 340 | 341 | % v1.0 96-06-14. Niclas Borlin, niclas@cs.umu.se. 342 | 343 | n=size(A,1); 344 | 345 | while (1) 346 | % Move assignment in column l to row r. 347 | C(l)=r; 348 | 349 | % Find zero to be removed from zero list.. 350 | 351 | % Find zero before this. 352 | m=find(A(r,:)==-l); 353 | 354 | % Link past this zero. 355 | A(r,m)=A(r,l); 356 | 357 | A(r,l)=0; 358 | 359 | % If this was the first zero of the path.. 360 | if (LR(r)<0) 361 | ...remove row from unassigned row list and return. 362 | U(n+1)=U(r); 363 | U(r)=0; 364 | return; 365 | else 366 | 367 | % Move back in this row along the path and get column of next zero. 368 | l=LR(r); 369 | 370 | % Insert zero at (r,l) first in zero list. 371 | A(r,l)=A(r,n+1); 372 | A(r,n+1)=-l; 373 | 374 | % Continue back along the column to get row of next zero in path. 375 | r=LC(l); 376 | end 377 | end 378 | 379 | 380 | function [A,CH,RH]=hmreduce(A,CH,RH,LC,LR,SLC,SLR) 381 | %HMREDUCE Reduce parts of cost matrix in the Hungerian method. 382 | % 383 | %[A,CH,RH]=hmreduce(A,CH,RH,LC,LR,SLC,SLR) 384 | %Input: 385 | %A - Cost matrix. 386 | %CH - vector of column of 'next zeros' in each row. 387 | %RH - vector with list of unexplored rows. 388 | %LC - column labels. 389 | %RC - row labels. 390 | %SLC - set of column labels. 391 | %SLR - set of row labels. 392 | % 393 | %Output: 394 | %A - Reduced cost matrix. 395 | %CH - Updated vector of 'next zeros' in each row. 396 | %RH - Updated vector of unexplored rows. 397 | 398 | % v1.0 96-06-14. Niclas Borlin, niclas@cs.umu.se. 399 | 400 | n=size(A,1); 401 | 402 | % Find which rows are covered, i.e. unlabelled. 403 | coveredRows=LR==0; 404 | 405 | % Find which columns are covered, i.e. labelled. 406 | coveredCols=LC~=0; 407 | 408 | r=find(~coveredRows); 409 | c=find(~coveredCols); 410 | 411 | % Get minimum of uncovered elements. 412 | m=min(min(A(r,c))); 413 | 414 | % Subtract minimum from all uncovered elements. 415 | A(r,c)=A(r,c)-m; 416 | 417 | % Check all uncovered columns.. 418 | for j=c 419 | % ...and uncovered rows in path order.. 420 | for i=SLR 421 | % If this is a (new) zero.. 422 | if (A(i,j)==0) 423 | % If the row is not in unexplored list.. 424 | if (RH(i)==0) 425 | % ...insert it first in unexplored list. 426 | RH(i)=RH(n+1); 427 | RH(n+1)=i; 428 | % Mark this zero as "next free" in this row. 429 | CH(i)=j; 430 | end 431 | % Find last unassigned zero on row I. 432 | row=A(i,:); 433 | colsInList=-row(row<0); 434 | if (length(colsInList)==0) 435 | % No zeros in the list. 436 | l=n+1; 437 | else 438 | l=colsInList(row(colsInList)==0); 439 | end 440 | % Append this zero to end of list. 441 | A(i,l)=-j; 442 | end 443 | end 444 | end 445 | 446 | % Add minimum to all doubly covered elements. 447 | r=find(coveredRows); 448 | c=find(coveredCols); 449 | 450 | % Take care of the zeros we will remove. 451 | [i,j]=find(A(r,c)<=0); 452 | 453 | i=r(i); 454 | j=c(j); 455 | 456 | for k=1:length(i) 457 | % Find zero before this in this row. 458 | lj=find(A(i(k),:)==-j(k)); 459 | % Link past it. 460 | A(i(k),lj)=A(i(k),j(k)); 461 | % Mark it as assigned. 462 | A(i(k),j(k))=0; 463 | end 464 | 465 | A(r,c)=A(r,c)+m; -------------------------------------------------------------------------------- /gitlocal/clusterings/matlab.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c62c3a7c22e3a7dcfd27db33a637a719cea468cb796e5e998aa8924bb3e495ec 3 | size 278 4 | -------------------------------------------------------------------------------- /gitlocal/clusterings/nmipp.m: -------------------------------------------------------------------------------- 1 | function MIhat = nmipp( A, B ) 2 | %NMI Normalized mutual information 3 | % http://en.wikipedia.org/wiki/Mutual_information 4 | % http://nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-clustering-1.html 5 | % Author: http://www.cnblogs.com/ziqiao/ [2011/12/15] 6 | if length( A ) ~= length( B) 7 | error('length( A ) must == length( B)'); 8 | end 9 | total = length(A); 10 | A_ids = unique(A); 11 | A_class = length(A_ids); 12 | B_ids = unique(B); 13 | B_class = length(B_ids); 14 | % Mutual information 15 | idAOccur = double (repmat( A, A_class, 1) == repmat( A_ids', 1, total )); 16 | idBOccur = double (repmat( B, B_class, 1) == repmat( B_ids', 1, total )); 17 | idABOccur = idAOccur * idBOccur'; 18 | Px = sum(idAOccur') / total; 19 | Py = sum(idBOccur') / total; 20 | Pxy = idABOccur / total; 21 | MImatrix = Pxy .* log2(Pxy ./(Px' * Py)+eps); 22 | MI = sum(MImatrix(:)) 23 | % Entropies 24 | Hx = -sum(Px .* log2(Px + eps),2); 25 | Hy = -sum(Py .* log2(Py + eps),2); 26 | %Normalized Mutual information 27 | MIhat = 2 * MI / (Hx+Hy); 28 | 29 | % MIhat = MI / sqrt(Hx*Hy); another version of NMI 30 | 31 | end 32 | 33 | -------------------------------------------------------------------------------- /gitlocal/clusterings/principlecoms.m: -------------------------------------------------------------------------------- 1 | function [ Vk ] = principlecoms( U,V,k ) 2 | %PRINCIPLECOMS Summary of this function goes here 3 | % Detailed explanation goes here 4 | [m,n]= size(U); 5 | normuvec=[]; 6 | for i=1:n 7 | normuvec = [normuvec norm(U(:,i))]; 8 | end 9 | [normsvec, index]=sort(normuvec,'descend'); 10 | Vk = V(:,index(1:k)); 11 | end 12 | 13 | -------------------------------------------------------------------------------- /gitlocal/clusterings/spectralclustering.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junwang929/subspace-clustering/48c68d32133ceb92b90454de517c3a3d3368539d/gitlocal/clusterings/spectralclustering.m -------------------------------------------------------------------------------- /gitlocal/imagenet100data.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ea0ef4ac51dba46ef7885d4c1145be15cc695d4ea1866b3617abffebcb040700 3 | size 686223412 4 | -------------------------------------------------------------------------------- /gitlocal/imagenet100label.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d3ad14d4533e62b36fb2f2fbd73411b6c4f84a9ab57b4eff52b7ae4fa206e2a4 3 | size 5331 4 | -------------------------------------------------------------------------------- /gitlocal/mnistdata.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3fd779431c51263b9d66e234fbcb48769c190387d623efd82fe39e8371658fc2 3 | size 26552041 4 | -------------------------------------------------------------------------------- /gitlocal/mnistlabel.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:501ad94bc39d7c2b7c286a670fabb1d03dd4b33701381b70ba298a3fbf9cb79f 3 | size 433 4 | -------------------------------------------------------------------------------- /gitlocal/protein.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8619b8d1fd31a2b6660ff0f1c0fac8e5b80efab1238c99a15954523ee79c530a 3 | size 50882072 4 | -------------------------------------------------------------------------------- /gitlocal/sytheticdata.m: -------------------------------------------------------------------------------- 1 | function [ U,data,E] = sytheticdata( dimension,n_subspace,n_base,n_sample,rho) 2 | % Generating data 3 | % n_subspace: number of subspaces 4 | % n_base: number of basis in each subspace 5 | % n_sample: number of samples from each subspace 6 | basis =orth(randn(dimension,dimension)); 7 | % Generating data based on 'basis' 8 | U = [ ]; 9 | data = [ ]; 10 | for i = 1: n_subspace 11 | start_idx = 1+ (i-1)*n_base; 12 | end_idx = i*n_base; 13 | if end_idx > dimension 14 | error('cannot produce disjoint subspaces'); 15 | end 16 | U_base = basis( :,start_idx:end_idx); 17 | V_base = randn(n_sample,n_base); 18 | U = [U U_base]; 19 | 20 | data_base = U_base*(V_base)'; 21 | data = [data data_base]; 22 | end 23 | 24 | num_elements = dimension * n_subspace*n_sample; 25 | temp = randperm(num_elements) ; 26 | numCorruptedEntries = round(rho * num_elements) ; 27 | corruptedPositions = temp(1:numCorruptedEntries) ; 28 | E = zeros(dimension, n_subspace*n_sample); 29 | E(corruptedPositions) = 20 *(rand(numCorruptedEntries, 1) - 0.5) ; 30 | 31 | 32 | end 33 | 34 | -------------------------------------------------------------------------------- /gitlocal/test_Imagenet.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = test_Imagenet(root_dir,carryon) 2 | 3 | load imagenet100data.mat; 4 | load imagenet100label.mat; 5 | %numset = [ 12700 22700 32700 42700 52700 62700 72700]; 6 | %arank = [ 90 100 250 350 450 550 600]; 7 | numset = [32700 62700]; 8 | arank = [250 550]; 9 | % ini = [ 214,327,62]; 10 | ini =[214]; 11 | %maxNumCompThreads(1); 12 | warning('off'); 13 | % To remove the mx in imagenet100.mat which is very memory consuming; 14 | mx=x'; 15 | mx = mx(:,1:80000); 16 | clear x; 17 | my = y(:,1:80000); 18 | if nargin <2 19 | carryon = 1; 20 | end 21 | for i= 0 : 1 22 | j = floor(i/size(ini,2))+1; 23 | start = ini( mod(i,size(ini,2))+1) 24 | data = mx(:,start : (start + numset(j)-1)); 25 | label = my(:,start : (start + numset(j)-1)); 26 | fprintf('Imagenet with size %g, rank %g\n', numset(j),arank(j)); 27 | %% Initiliazing: 28 | U = 0.00001* rand(numset(j),arank(j)); 29 | if numset(j) >52700 30 | U = 0.1*U; 31 | end 32 | V = rand(numset(j),arank(j)); 33 | initialvalue.U = U; 34 | initialvalue.V = V; 35 | parameter.rank = arank(j); 36 | parameter.epsilon = 0.005; 37 | parameter.inner = 3; 38 | if ~exist(root_dir, 'dir') 39 | mkdir(root_dir) 40 | end 41 | if carryon ==1 42 | %% NLRR++ 43 | [results_nlrrp] = wholeline( data,label,'NLRR++',initialvalue,parameter); 44 | data_file = [root_dir 'nlrrp' num2str(j) '_' num2str(start) '.mat']; 45 | save(data_file, 'results_nlrrp'); 46 | fprintf('save to %s\n', data_file); 47 | %% NLRR 48 | [results_nlrr] = wholeline( data,label,'NLRR',initialvalue,parameter); 49 | data_file = [root_dir 'nlrr' num2str(j) '_' num2str(start) '.mat']; 50 | save(data_file, 'results_nlrr'); 51 | fprintf('save to %s\n', data_file); 52 | %% OLRSC 53 | [results_olrsc] = wholeline( data,label,'OLRSC',0,parameter); 54 | data_file = [root_dir 'olrsc' num2str(j) '_' num2str(start) '.mat']; 55 | save(data_file, 'results_olrsc'); 56 | fprintf('save to %s\n', data_file); 57 | %% ORPCA 58 | [results_orpca] = wholeline( data,label,'ORPCA',0,parameter); 59 | data_file = [root_dir 'orpca' num2str(j) '_' num2str(start) '.mat']; 60 | save(data_file, 'results_orpca'); 61 | fprintf('save to %s\n', data_file); 62 | %% LRR 63 | [results_lrr] = wholeline( data,label,'LRR',0,parameter); 64 | data_file = [root_dir 'lrr' num2str(j) '_' num2str(start) '.mat']; 65 | save(data_file, 'results_lrr'); 66 | fprintf('save to %s\n', data_file); 67 | % %% SSC 68 | % [results_ssc] = wholeline( data,label,'SSC'); 69 | % data_file = [root_dir 'ssc' num2str(j) '_' num2str(start) '.mat' ]; 70 | % save(data_file, 'results_ssc'); 71 | % fprintf('save to %s\n', data_file); 72 | end 73 | end 74 | 75 | 76 | end 77 | -------------------------------------------------------------------------------- /gitlocal/test_Mnist.m: -------------------------------------------------------------------------------- 1 | function [ ] = test_Mnist(root_dir,carryon) 2 | %TEST_MNIST Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | load mnistdata.mat; 6 | load mnistlabel.mat; 7 | numset = [22700 ]; 8 | arank = [90 ]; 9 | ini=[ 1, 89, 214]; 10 | warning('off'); 11 | %maxNumCompThreads(1); 12 | %for i = 0:2 13 | i =0; 14 | j = floor(i/size(ini,2))+1; 15 | start =ini( mod(i,size(ini,2))+1) 16 | data = data(:,start : (start + numset(j)-1)); 17 | label = label(:,start : (start + numset(j)-1)); 18 | U = 0.00001*rand(numset(j),arank(j)); 19 | V = rand(numset(j),arank(j)); 20 | initialvalue.U = U; 21 | initialvalue.V = V; 22 | parameter.rank = arank(j); 23 | parameter.epsilon = 0.005; 24 | parameter.inner = 3; 25 | fprintf('MNIST with size %g, rank %g\n', numset(j),arank(j)); 26 | %% saving results: 27 | if ~exist(root_dir, 'dir') 28 | mkdir(root_dir) 29 | end 30 | if nargin <2 31 | carryon = 1; 32 | end 33 | %% NLRR++ 34 | [results_nlrrp] = wholeline( data,label,'NLRR++',initialvalue,parameter); 35 | data_file = [root_dir 'nlrrp.mat']; 36 | save(data_file, 'results_nlrrp'); 37 | fprintf('save to %s\n', data_file); 38 | %% NLRR 39 | [results_nlrr] = wholeline( data,label,'NLRR',initialvalue,parameter); 40 | data_file = [root_dir 'nlrr.mat']; 41 | save(data_file, 'results_nlrr'); 42 | fprintf('save to %s\n', data_file); 43 | if carryon == 1 44 | %% OLRSC 45 | [results_olrsc] = wholeline( data,label,'OLRSC',0,parameter); 46 | data_file = [root_dir 'olrsc.mat']; 47 | save(data_file, 'results_olrsc'); 48 | fprintf('save to %s\n', data_file); 49 | %% ORPCA 50 | [results_orpca] = wholeline( data,label,'ORPCA',0,parameter); 51 | data_file = [root_dir 'orpca.mat']; 52 | save(data_file, 'results_orpca'); 53 | fprintf('save to %s\n', data_file); 54 | %% LRR 55 | [results_lrr] = wholeline( data,label,'LRR',0,parameter); 56 | data_file = [root_dir 'lrr.mat']; 57 | save(data_file, 'results_lrr'); 58 | fprintf('save to %s\n', data_file); 59 | %% SSC 60 | [results_ssc] = wholeline( data,label,'SSC'); 61 | data_file = [root_dir 'ssc.mat']; 62 | save(data_file, 'results_ssc'); 63 | fprintf('save to %s\n', data_file); 64 | end 65 | %end 66 | 67 | end 68 | 69 | -------------------------------------------------------------------------------- /gitlocal/test_Protein.m: -------------------------------------------------------------------------------- 1 | function [ ] = test_Protein(root_dir,carryon) 2 | 3 | load 'protein.mat'; 4 | warning('off'); 5 | nk = 3 6 | rank = 90 7 | data = data'; 8 | [m,n] = size(data); 9 | % [U,S,V] = svds( data'*data,rank); 10 | % U = U*sqrt(S); 11 | % V = V*sqrt(S); 12 | U = 0.0001* rand(n,rank); 13 | V = 0.1* rand(n,rank); 14 | 15 | %maxNumCompThreads(1); 16 | initialvalue.U = U; 17 | initialvalue.V = V; 18 | parameter.rank = rank; 19 | parameter.epsilon = 0.005; 20 | parameter.inner = 3; 21 | fprintf('Protein with size %g, rank %g\n', n, rank); 22 | if ~exist(root_dir, 'dir') 23 | mkdir(root_dir) 24 | end 25 | if nargin <2 26 | carryon = 1; 27 | end 28 | %% NLRR++ 29 | [results_nlrrp] = wholeline( data,label,'NLRR++',initialvalue,parameter); 30 | data_file = [root_dir 'nlrrp.mat']; 31 | save(data_file, 'results_nlrrp'); 32 | fprintf('save to %s\n', data_file); 33 | %% NLRR 34 | [results_nlrr] = wholeline( data,label,'NLRR',initialvalue,parameter); 35 | data_file = [root_dir 'nlrr.mat']; 36 | save(data_file, 'results_nlrr'); 37 | fprintf('save to %s\n', data_file); 38 | if carryon ==1 39 | %% OLRSC 40 | [results_olrsc] = wholeline( data,label,'OLRSC',0,parameter); 41 | data_file = [root_dir 'olrsc.mat']; 42 | save(data_file, 'results_olrsc'); 43 | fprintf('save to %s\n', data_file); 44 | %% ORPCA 45 | [results_orpca] = wholeline( data,label,'ORPCA',0,parameter); 46 | data_file = [root_dir 'orpca.mat']; 47 | save(data_file, 'results_orpca'); 48 | fprintf('save to %s\n', data_file); 49 | %% LRR 50 | [results_lrr] = wholeline( data,label,'LRR',0,parameter); 51 | data_file = [root_dir 'lrr.mat']; 52 | save(data_file, 'results_lrr'); 53 | fprintf('save to %s\n', data_file); 54 | %% SSC 55 | [results_ssc] = wholeline( data,label,'SSC'); 56 | data_file = [root_dir 'ssc.mat']; 57 | save(data_file, 'results_ssc'); 58 | fprintf('save to %s\n', data_file); 59 | end 60 | end 61 | 62 | -------------------------------------------------------------------------------- /gitlocal/test_SVHN.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = test_SVHN( root_dir,carryon) 2 | 3 | load 'SVHN.mat'; 4 | warning('off'); 5 | addpath('clusterings/'); 6 | % maxNumCompThreads(1); 7 | data = data'./255; 8 | [label,indlabel] = sort(label,'ascend'); 9 | data = data(:,indlabel); 10 | data = data(1:2:size(data,1),:); 11 | sizedata = size(data,1) 12 | data = data(:,3000:12000); 13 | size(data,2) 14 | label = label(:,3000:12000); 15 | nk = calnumber(label); 16 | rank = nk*70 17 | 18 | %% Initiliazing: 19 | % [U,S,V] = svds( data'*data,rank); 20 | % U = 0.9*U*sqrt(S) ; 21 | % V = 0.9*V*sqrt(S) ; 22 | U = 0.00001*rand(size(data,2),rank); 23 | V = 0.01*rand(size(data,2),rank); 24 | initialvalue.U = U; 25 | initialvalue.V = V; 26 | parameter.rank = rank; 27 | parameter.epsilon = 0.005; 28 | parameter.inner = 3; 29 | fprintf('SVHN with size %g, rank %g\n', 9001,rank); 30 | 31 | if ~exist(root_dir, 'dir') 32 | mkdir(root_dir) 33 | end 34 | if nargin <2 35 | carryon = 1; 36 | end 37 | %% NLRR++ 38 | [results_nlrrp] = wholeline( data,label,'NLRR++',initialvalue,parameter); 39 | data_file = [root_dir 'nlrrp.mat']; 40 | save(data_file, 'results_nlrrp'); 41 | fprintf('save to %s\n', data_file); 42 | %% NLRR 43 | [results_nlrr] = wholeline( data,label,'NLRR',initialvalue,parameter); 44 | data_file = [root_dir 'nlrr.mat']; 45 | save(data_file, 'results_nlrr'); 46 | fprintf('save to %s\n', data_file); 47 | if carryon ==1 48 | %% OLRSC 49 | [results_olrsc] = wholeline( data,label,'OLRSC',0,parameter); 50 | data_file = [root_dir 'olrsc.mat']; 51 | save(data_file, 'results_olrsc'); 52 | fprintf('save to %s\n', data_file); 53 | %% ORPCA 54 | [results_orpca] = wholeline( data,label,'ORPCA',0,parameter); 55 | data_file = [root_dir 'orpca.mat']; 56 | save(data_file, 'results_orpca'); 57 | fprintf('save to %s\n', data_file); 58 | %% LRR 59 | [results_lrr] = wholeline( data,label,'LRR',0,parameter); 60 | data_file = [root_dir 'lrr.mat']; 61 | save(data_file, 'results_lrr'); 62 | fprintf('save to %s\n', data_file); 63 | % %% SSC 64 | % [results_ssc] = wholeline( data,label,'SSC'); 65 | % data_file = [root_dir 'ssc.mat']; 66 | % save(data_file, 'results_ssc'); 67 | % fprintf('save to %s\n', data_file); 68 | end 69 | end 70 | 71 | -------------------------------------------------------------------------------- /gitlocal/test_Usps.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = test_Usps( root_dir,carryon) 2 | 3 | load 'usps.mat'; 4 | warning('off'); 5 | nk = 10; 6 | rank = 50 7 | data = data'; 8 | %maxNumCompThreads(1); 9 | %% Initiliazing: 10 | % U = 0.00001* rand(size(data,2),rank); 11 | % V = rand(size(data,2),rank); 12 | load U_usps.mat; 13 | load V_usps.mat; 14 | initialvalue.U = U; 15 | initialvalue.V = V; 16 | parameter.rank = rank; 17 | parameter.epsilon = 0.005; 18 | parameter.inner = 3; 19 | if ~exist(root_dir, 'dir') 20 | mkdir(root_dir) 21 | end 22 | if nargin <2 23 | carryon = 1; 24 | end 25 | %% NLRR++ 26 | [results_nlrrp,obj1] = wholeline( data,label,'NLRR++',initialvalue,parameter); 27 | data_file = [root_dir 'nlrrp.mat']; 28 | save(data_file, 'results_nlrrp'); 29 | fprintf('save to %s\n', data_file); 30 | %% NLRR 31 | [results_nlrr,obj2] = wholeline( data,label,'NLRR',initialvalue,parameter); 32 | data_file = [root_dir 'nlrr.mat']; 33 | save(data_file, 'results_nlrr'); 34 | fprintf('save to %s\n', data_file); 35 | 36 | if carryon ==1 37 | %% OLRSC 38 | [results_olrsc] = wholeline( data,label,'OLRSC',0,parameter); 39 | data_file = [root_dir 'olrsc.mat']; 40 | save(data_file, 'results_olrsc'); 41 | fprintf('save to %s\n', data_file); 42 | %% ORPCA 43 | [results_orpca] = wholeline( data,label,'ORPCA',0,parameter); 44 | data_file = [root_dir 'orpca.mat']; 45 | save(data_file, 'results_orpca'); 46 | fprintf('save to %s\n', data_file); 47 | %% LRR 48 | [results_lrr] = wholeline( data,label,'LRR',0,parameter); 49 | data_file = [root_dir 'lrr.mat']; 50 | save(data_file, 'results_lrr'); 51 | fprintf('save to %s\n', data_file); 52 | %% SSC 53 | [results_ssc] = wholeline( data,label,'SSC'); 54 | data_file = [root_dir 'ssc.mat']; 55 | save(data_file, 'results_ssc'); 56 | fprintf('save to %s\n', data_file); 57 | end 58 | end 59 | 60 | -------------------------------------------------------------------------------- /gitlocal/testall.m: -------------------------------------------------------------------------------- 1 | % clear all; 2 | root_dir = [ 'Result/']; 3 | root_dir = [root_dir 'mnist_mul/']; 4 | test_Mnist(root_dir); 5 | clear all; 6 | root_dir = [root_dir 'protein_mul/']; 7 | test_Protein(root_dir); 8 | clear all; 9 | root_dir = [root_dir 'svhn_mul/']; 10 | test_SVHN(root_dir); 11 | clear all; 12 | root_dir = [root_dir 'usps_mul/']; 13 | test_Usps(root_dir); 14 | clear all; 15 | root_dir = [root_dir 'imagenet_mul/']; 16 | test_Imagenet(root_dir); 17 | maxNumCompThreads(1); 18 | clear all; 19 | root_dir = [ 'Result/']; 20 | root_dir = [root_dir 'mnist_sin/']; 21 | test_Mnist(root_dir); 22 | clear all; 23 | root_dir = [root_dir 'protein_sin/']; 24 | test_Protein(root_dir); 25 | clear all; 26 | root_dir = [root_dir 'svhn_sin/']; 27 | test_SVHN(root_dir); 28 | clear all; 29 | root_dir = [root_dir 'usps_sin/']; 30 | test_Usps(root_dir); 31 | clear all; 32 | root_dir = [root_dir 'imagenet_sin/']; 33 | test_Imagenet(root_dir); 34 | -------------------------------------------------------------------------------- /gitlocal/testsimulation.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | warning('off'); 3 | addpath('NLRRSS/'); 4 | addpath('clusterings/'); 5 | dimension = 1000; 6 | i=4; 7 | K=i; 8 | n_base = 40; 9 | rho = 0.02; 10 | lambda = 1/sqrt(dimension)*30; 11 | n_sample =3000; 12 | % for n_sample = 2400:400:4000 13 | task ='simulation_sin'; 14 | root_dir = ['Result/' task '/']; 15 | if ~exist(root_dir, 'dir') 16 | mkdir(root_dir) 17 | end 18 | 19 | for n_base = 40:5:90 20 | partpath = n_base; 21 | fprintf('rho = %g \n',rho); 22 | [U,data,E] = sytheticdata( dimension,i,n_base,n_sample,rho); 23 | data = data + E; 24 | disp(['rank(dataE)= ' num2str(rank(data))]); 25 | label =zeros(1,i*n_sample); 26 | %% label 27 | for ii=1:i*n_sample 28 | label(ii) = ceil(ii/n_sample); 29 | end 30 | 31 | %% NLRRS4 32 | n =i*n_sample; 33 | U0 = 0.0001*rand(n,i*n_base); 34 | V0 = rand(n,i*n_base); 35 | L = orth(data*U0); 36 | initialvalue.U = U0; 37 | initialvalue.V = V0; 38 | parameter.rank = n_base*i; 39 | parameter.epsilon = 0.005; 40 | parameter.inner = 3; 41 | fprintf('Simulation data with size %g, rank %g\n', n, parameter.rank); 42 | %% NLRR++ 43 | tic; 44 | [US1,VS1] = NLRRplusE(data,data,U0,V0,0.8,parameter.rank,parameter.epsilon,parameter.inner,lambda); 45 | %[fvalue_S1,ACCS1,S1,cTS1] = wholeline( data,label,'NLRR++',initialvalue,parameter,'spectralclustering'); 46 | TS = toc; 47 | tic; 48 | [idx, fvalue_S]= spectralclustering(US1*VS1',label,K); 49 | cT = toc; 50 | grps = bestMap(label,idx); 51 | ACCS = 1-sum(label(:) ~= grps(:)) / length(label); 52 | results_nlrrp.fvalue = fvalue_S; 53 | results_nlrrp.ACC=ACCS; 54 | results_nlrrp.Time = TS; 55 | fprintf('NLRR++: Time %g,F_value %g, ACC %g,clusteringT %g\n',TS,fvalue_S,ACCS,cT); 56 | data_file = [root_dir num2str(partpath) 'nlrrp.mat']; 57 | save(data_file, 'results_nlrrp'); 58 | fprintf('save to %s\n', data_file); 59 | %% NLRR 60 | tic; 61 | [US,VS] = NLRRE(data,data,U0,V0,0.8,parameter.rank,parameter.epsilon,lambda); 62 | TSn =toc; 63 | tic; 64 | [idxn, fvalue_Sn]= spectralclustering(US*VS',label,K); 65 | cTn = toc; 66 | grps = bestMap(label,idxn); 67 | ACCSn = 1-sum(label(:) ~= grps(:)) / length(label); 68 | fprintf('NLRR: Time %g,F_value %g, ACC %g, clusteringT %g\n',TSn,fvalue_Sn,ACCSn,cTn); 69 | results_nlrr.fvalue = fvalue_Sn; 70 | results_nlrr.ACC=ACCSn; 71 | results_nlrr.Time = TSn; 72 | data_file = [root_dir num2str(partpath) 'nlrr.mat']; 73 | save(data_file, 'results_nlrr'); 74 | fprintf('save to %s\n', data_file); 75 | %% OLRSC 76 | [results_olrsc] = wholeline( data,label,'OLRSC',0,parameter,'spectralclustering'); 77 | data_file = [root_dir num2str(partpath) 'olrsc.mat']; 78 | save(data_file, 'results_olrsc'); 79 | fprintf('save to %s\n', data_file); 80 | %% ORPCA 81 | [results_orpca] = wholeline( data,label,'ORPCA',0,parameter,'spectralclustering'); 82 | data_file = [root_dir num2str(partpath) 'orpca.mat']; 83 | save(data_file, 'results_orpca'); 84 | fprintf('save to %s\n', data_file); 85 | %% LRR 86 | [results_lrr] = wholeline( data,label,'LRR',0,parameter,'spectralclustering'); 87 | data_file = [root_dir num2str(partpath) 'lrr.mat']; 88 | save(data_file, 'results_lrr'); 89 | fprintf('save to %s\n', data_file); 90 | % %% SSC 91 | % [results_ssc] = wholeline( data,label,'SSC',0,parameter,'spectralclustering'); 92 | % data_file = [root_dir num2str(partpath) 'ssc.mat']; 93 | % save(data_file, 'results_ssc'); 94 | % fprintf('save to %s\n', data_file); 95 | end 96 | 97 | 98 | -------------------------------------------------------------------------------- /gitlocal/usps.mat: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:db22be5db0b8680e2d807f6e367a1d6890cd0b7c3d0a685bfd500c852cabb245 3 | size 14990544 4 | -------------------------------------------------------------------------------- /gitlocal/wholeline.m: -------------------------------------------------------------------------------- 1 | function [ results] = wholeline(data,label,method,initialvalue,parameter,clustermethod,iscluster) 2 | %WHOLELINE Summary of this function goes here 3 | % Detailed explanation goes here 4 | addpath('NLRRSS/'); 5 | addpath('clusterings/'); 6 | addpath('OLRSC/'); 7 | addpath('ORPCA/'); 8 | addpath('SSC/'); 9 | addpath('LRR/'); 10 | K = calnumber(label); 11 | fvalue_S =0; 12 | ACCS =0; 13 | nmis =0; 14 | S3 =0; 15 | cT =0; 16 | if nargin < 6 17 | clustermethod = 'clustering'; 18 | iscluster = 1; 19 | end 20 | fprintf ('Method: %s ----\n', method); 21 | switch(method) 22 | case 'NLRR++' 23 | %% 24 | U = initialvalue.U; 25 | V = initialvalue.V; 26 | rank = parameter.rank; 27 | epsilon = parameter.epsilon; 28 | inner = parameter.inner; 29 | tic; 30 | [US1,VS1,obj,time] = NLRRplus(data,data,U,V,0.8,rank,epsilon,inner); 31 | %[US1,VS1] = NLRRplusE(data,data,U,V,0.8,rank,epsilon,inner,40); 32 | S3=toc; 33 | 34 | if iscluster == 1 35 | [fvalue_S,ACCS,cT, nmis] = clusterout(US1,VS1,label,K,clustermethod); 36 | fprintf('NLRR++: Time %g, F_value %g, ACC %g, clusterTime %g,nmis %g \n', S3, fvalue_S, ACCS,cT,nmis ); 37 | end 38 | results.obj = obj; 39 | results.time = time; 40 | case 'NLRR' 41 | %% 42 | U = initialvalue.U; 43 | V = initialvalue.V; 44 | rank = parameter.rank; 45 | epsilon = parameter.epsilon; 46 | inner = parameter.inner; 47 | tic; 48 | [US1,VS1,obj,time] = NLRR(data,data,U,V,0.8,rank,epsilon); 49 | 50 | % [US1,VS1] = NLRRE(data,data,U,V,0.8,rank,epsilon,40); 51 | S3=toc; 52 | if iscluster ==1 53 | [fvalue_S,ACCS,cT, nmis] = clusterout(US1,VS1,label,K,clustermethod); 54 | fprintf('NLRR: Time %g, F_value %g, ACC %g, clusterTime %g,nmis %g \n', S3, fvalue_S, ACCS,cT,nmis ); 55 | end 56 | results.obj = obj; 57 | results.time = time; 58 | case 'OLRSC' 59 | %% 60 | epochs =2; 61 | Z = data; 62 | [p, n] = size(Z); 63 | lambda1 = 1; 64 | lambda2 = 1/sqrt(p); 65 | lambda3_base = 1/sqrt(p); 66 | d = parameter.rank; 67 | M = zeros(p, d); 68 | A = zeros(d, d); 69 | B = zeros(p, d); 70 | U = zeros(n, d); 71 | V = zeros(n, d); 72 | D = randn(p, d); 73 | tic; 74 | for ep=1:epochs 75 | for t=1:n 76 | if mod(t, 1000) == 0 77 | fprintf('OLRSC: access sample %d\n', t); 78 | end 79 | z = Z(:, t); 80 | lambda3 = sqrt(t) * lambda3_base; 81 | [v, e] = OLRR_solve_ve(z, D, lambda1, lambda2); 82 | normz = norm(z); 83 | u = (D - M)' * z / (normz * normz + 1/lambda3); 84 | M = M + z * u'; 85 | A = A + v * v'; 86 | B = B + (z-e) * v'; 87 | D = OLRR_solve_D(D, M, A, B, lambda1, lambda3); 88 | U(t, :) = u'; 89 | V(t, :) = v'; 90 | end 91 | M = zeros(p, d); 92 | end 93 | S3=toc; 94 | [fvalue_S,ACCS,cT, nmis] = clusterout(U,V,label,K,clustermethod); 95 | fprintf('OLRSC: Time %g, F_value %g, ACC %g, clusterTime %g,nmis %g \n', S3, fvalue_S, ACCS,cT, nmis); 96 | case 'ORPCA' 97 | %% 98 | epochs = 2; 99 | Z = data; 100 | [p, n] = size(Z); 101 | lambda1 = 1/sqrt(p); 102 | lambda2 = 1/sqrt(p); 103 | d = parameter.rank; 104 | L = randn(p, d); 105 | R = zeros(n, d); 106 | A = zeros(d, d); 107 | B = zeros(p, d); 108 | tic; 109 | for ep=1:epochs 110 | for t=1:n 111 | if mod(t, 1000) == 0 112 | fprintf('OR-PCA: access sample %d\n', t); 113 | end 114 | z = Z(:, t); 115 | [r, e] = solve_proj2(z, L, lambda1, lambda2); 116 | A = A + r * r'; 117 | B = B + (z-e) * r'; 118 | L = update_col_orpca(L, A, B, lambda1); 119 | R(t, :) = r'; 120 | end 121 | end 122 | S3 = toc; 123 | X = L * R'; 124 | [~, SX, VX] = svds(X, d); 125 | [fvalue_S,ACCS,cT, nmis] = clusterout(VX,VX,label,K,clustermethod); 126 | fprintf('ORPCA++: Time %g, F_value %g, ACC %g, clusterTime %g,nmis %g \n', S3, fvalue_S, ACCS,cT, nmis); 127 | case 'SSC' 128 | %% 129 | Z = data; 130 | [p, n] = size(Z); 131 | % The following is exactly what SSC does but we test the running time of SSC and spectral clutering separably. 132 | tic; 133 | Z = DataProjection(Z, 0); 134 | CMat = admmOutlier_mat_func(Z, false, 20); 135 | N = size(Z, 2); 136 | X = CMat(1:N, :); 137 | S3 = toc 138 | tic; 139 | [idx, fvalue_S]= spectralclustering(X,label,K); 140 | grps = bestMap(label,idx); 141 | ACCS = 1-sum(label(:) ~= grps(:)) / length(label); 142 | nmis = NMI(idx,label); 143 | cT = toc; 144 | fprintf('SSC: Time %g, F_value %g, ACC %g, clusterTime %g,nmis %g \n', S3, fvalue_S, ACCS,cT, nmis); 145 | case 'LRR' 146 | %% 147 | d= parameter.rank; 148 | Z = data; 149 | [p, n] = size(Z); 150 | tic; 151 | [X, ~] = solve_lrr(Z, Z, 1/sqrt(n), 1, 1,1); 152 | S3 = toc; 153 | [~, ~, VX] = svds(X, d); 154 | [fvalue_S,ACCS,cT, nmis] = clusterout(VX,VX,label,K,clustermethod); 155 | 156 | fprintf('LRR: Time %g, F_value %g, ACC %g, clusterTime %g,nmis %g \n', S3, fvalue_S, ACCS,cT, nmis); 157 | end 158 | results.fvalue=fvalue_S; 159 | results.ACC=ACCS; 160 | results.NMI = nmis; 161 | results.Time =S3; 162 | results.cT = cT; 163 | end 164 | function [fvalue_S,ACCS,cT, nmis] = clusterout(U,V,label,K,clustermethod) 165 | switch(clustermethod) 166 | case 'clustering' 167 | tic; 168 | [idx,fvalue_S] = clustering(U,V,label,K); 169 | cT = toc; 170 | case 'spectralclustering' 171 | tic; 172 | X = U*V'; 173 | [idx, fvalue_S]= spectralclustering(X,label,K); 174 | cT = toc; 175 | end 176 | grps = bestMap(label,idx); 177 | ACCS = 1-sum(label(:) ~= grps(:)) / length(label); 178 | nmis = NMI(idx,label); 179 | nmis2 = NMI(label,idx); 180 | % nmis3p = nmipp(idx,label); 181 | % nmis4p = nmipp(label,idx); 182 | % fprintf('nmis is %g, nmis2: is %g, nmis3p: is %g, nmis4p: is %g,\n',... 183 | % nmis, nmis2,nmis3p,nmis4p); 184 | fprintf('nmis is %g, nmis2: is %g \n',... 185 | nmis, nmis2); 186 | end 187 | 188 | --------------------------------------------------------------------------------