diff util/SMALL_learn.m @ 224:fd0b5d36f6ad danieleb

Updated the contents of this branch with the contents of the default branch.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 12 Apr 2012 13:52:28 +0100
parents 7426503fc4d1 a986ee86651e
children
line wrap: on
line diff
--- a/util/SMALL_learn.m	Wed Mar 14 16:31:38 2012 +0000
+++ b/util/SMALL_learn.m	Thu Apr 12 13:52:28 2012 +0100
@@ -1,9 +1,9 @@
 function DL = SMALL_learn(Problem,DL)
-%% SMALL Dictionary Learning   
-%   
-%   Function gets as input Problem and Dictionary Learning (DL) structures 
+%% SMALL Dictionary Learning
+%
+%   Function gets as input Problem and Dictionary Learning (DL) structures
 %   In Problem structure field b with the training set needs to be defined
-%   In DL fields with name of the toolbox and solver, and parameters file 
+%   In DL fields with name of the toolbox and solver, and parameters file
 %   for particular dictionary learning technique needs to be present.
 %
 %   Outputs are Learned dictionary and time spent as a part of DL structure
@@ -18,109 +18,31 @@
 %   License, or (at your option) any later version.  See the file
 %   COPYING included with this distribution for more information.
 %%
+
+SMALLboxInit
+
 if (DL.profile)
-  fprintf('\nStarting Dictionary Learning %s... \n', DL.name);
+    fprintf('\nStarting Dictionary Learning %s... \n', DL.name);
 end
-  start=cputime;
-  tStart=tic;
-  if strcmpi(DL.toolbox,'KSVD')
-    param=DL.param; 
-    param.data=Problem.b;
- 
-    D = eval([DL.name,'(param)']);%, ''t'', 5);']);
-  elseif strcmpi(DL.toolbox,'KSVDS')
-    param=DL.param; 
-    param.data=Problem.b;
-    
-    D = eval([DL.name,'(param, ''t'', 5);']);
-  elseif strcmpi(DL.toolbox,'SPAMS')
-    
-    X  = Problem.b; 
-    param=DL.param;
-    
-    D = eval([DL.name,'(X, param);']);
-    %   As some versions of SPAMS does not produce unit norm column
-    %   dictionaries, we need to make sure that columns are normalised to
-    %   unit lenght.
-    
-    for i = 1: size(D,2)
-        D(:,i)=D(:,i)/norm(D(:,i));
-    end
-  elseif strcmpi(DL.toolbox,'SMALL')
-    
-    X  = Problem.b; 
-    param=DL.param;
-    
-    D = eval([DL.name,'(X, param);']);
-    %   we need to make sure that columns are normalised to
-    %   unit lenght.
-    
-    for i = 1: size(D,2)
-        D(:,i)=D(:,i)/norm(D(:,i));
-    end
-    
-   elseif strcmpi(DL.toolbox,'TwoStepDL')
-        
-    DL=SMALL_two_step_DL(Problem, DL);
-    
-    %   we need to make sure that columns are normalised to
-    %   unit lenght.
-    
-    for i = 1: size(DL.D,2)
-        DL.D(:,i)=DL.D(:,i)/norm(DL.D(:,i));
-    end
-    D = DL.D;
-    
-elseif strcmpi(DL.toolbox,'MMbox')
-        
-    DL = wrapper_mm_DL(Problem, DL);
-    
-    %   we need to make sure that columns are normalised to
-    %   unit lenght.
-    
-    for i = 1: size(DL.D,2)
-        DL.D(:,i)=DL.D(:,i)/norm(DL.D(:,i));
-    end
-    D = DL.D; 
 
-elseif strcmpi(DL.toolbox,'dl_ramirez')
-	DL = dl_ramirez(Problem,DL);
-	D = normcol(DL.D);
-    
-%   To introduce new dictionary learning technique put the files in
-%   your Matlab path. Next, unique name <TolboxID> for your toolbox needs 
-%   to be defined and also prefferd API for toolbox functions <Preffered_API>
-%   
-% elseif strcmpi(DL.toolbox,'<ToolboxID>')
-%     % This is an example of API that can be used:
-%     % - get training set from Problem part of structure
-%     % - assign parameters defined in the main program
-%
-%     X  = Problem.b; 
-%     param=DL.param;
-%
-%     % - Evaluate the function (DL.name - defined in the main) with
-%     %   parameters given above
-%
-%     D = eval([DL.name,'(<Preffered_API>);']);
+start=cputime;
+tStart=tic;
 
-  else
-    printf('\nToolbox has not been registered. Please change SMALL_learn file.\n');
-    return
-  end
-  
+% toolboxes configuration file
+run(fullfile(SMALL_path, 'config/SMALL_learn_config.m'));
+
 %%
 %   Dictionary Learning time
 tElapsed=toc(tStart);
 DL.time = cputime - start;
 if (DL.profile)
-  fprintf('\n%s finished task in %2f seconds (cpu time). \n', DL.name, DL.time);
-  fprintf('\n%s finished task in %2f seconds (tic-toc time). \n', DL.name, tElapsed);
+    fprintf('\n%s finished task in %2f seconds (cpu time). \n', DL.name, DL.time);
+    fprintf('\n%s finished task in %2f seconds (tic-toc time). \n', DL.name, tElapsed);
 end
 DL.time=tElapsed;
-%   If dictionary is given as a sparse matrix change it to full  
+%   If dictionary is given as a sparse matrix change it to full
 
-  DL.D = full(D);
-  
+DL.D = full(D);
+
 end
-  
+