changeset 190:759313488e7b luisf_dev

Added two config files for the 2 step dic and learn scripts; removed 'extra' folder; created init script (initial version).
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 13 Mar 2012 17:33:20 +0000
parents 3cc204120431
children d50f5bdbe14c
files DL/two-step DL/SMALL_two_step_DL.m SMALLboxInit.m config/SMALL_learn_config.m config/SMALL_two_step_DL_config.m extra/README.txt util/SMALL_learn.m
diffstat 6 files changed, 131 insertions(+), 121 deletions(-) [+]
line wrap: on
line diff
--- a/DL/two-step DL/SMALL_two_step_DL.m	Thu Feb 09 17:26:45 2012 +0000
+++ b/DL/two-step DL/SMALL_two_step_DL.m	Tue Mar 13 17:33:20 2012 +0000
@@ -30,7 +30,8 @@
 
 % initialize the dictionary %
 
-if (isfield(DL.param,'initdict'))
+% todo: check second if statement
+if (isfield(DL.param,'initdict')) && ~isempty(DL.param.initdict);
   if (any(size(DL.param.initdict)==1) && all(iswhole(DL.param.initdict(:))))
     dico = sig(:,DL.param.initdict(1:dictsize));
   else
@@ -110,11 +111,15 @@
 for i = 1:iternum
     Problem.A = dico;
     solver = SMALL_solve(Problem, solver);
-    [dico, solver.solution] = dico_update(dico, sig, solver.solution, ...
-        typeUpdate, flow, learningRate);
-    if (decorrelate)
-        dico = dico_decorr(dico, mu, solver.solution);
-    end
+    
+    % configuration file
+    run([SMALL_path '/config/SMALL_two_step_DL_config.m'])
+   
+%     [dico, solver.solution] = dico_update(dico, sig, solver.solution, ...
+%         typeUpdate, flow, learningRate);
+%     if (decorrelate)
+%         dico = dico_decorr(dico, mu, solver.solution);
+%     end
     
    if ((show_dictionary)&&(mod(i,show_iter)==0))
        dictimg = SMALL_showdict(dico,[8 8],...
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SMALLboxInit.m	Tue Mar 13 17:33:20 2012 +0000
@@ -0,0 +1,5 @@
+global SMALL_path;
+SMALL_path=pwd;
+
+% SMALL_p = genpath(SMALL_path);
+% addpath(SMALL_p);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/SMALL_learn_config.m	Tue Mar 13 17:33:20 2012 +0000
@@ -0,0 +1,83 @@
+
+
+  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; 
+    
+%   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>);']);
+
+  else
+    printf('\nToolbox has not been registered. Please change SMALL_learn file.\n');
+    return
+  end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/SMALL_two_step_DL_config.m	Tue Mar 13 17:33:20 2012 +0000
@@ -0,0 +1,30 @@
+
+    %DICTIONARY UPDATE STEP
+    if strcmpi(typeUpdate,'mocod')			%if update is MOCOD create parameters structure
+        mocodParams = struct('zeta',DL.param.zeta,...	%coherence regularization factor
+            'eta',DL.param.eta,...		%atoms norm regularization factor
+            'Dprev',dico);				%previous dictionary
+        % dico = dico_update(dico,sig,solver.solution,typeUpdate,flow,learningRate,mocodParams);
+        if ~isfield(DL.param,'decFcn'), DL.param.decFcn = 'none'; end
+
+        dico = dico_update_mocod(dico,sig,solver.solution,typeUpdate,flow,learningRate,mocodParams);
+           
+    else
+        [dico, solver.solution] = dico_update(dico, sig, solver.solution, ...
+            typeUpdate, flow, learningRate);
+        dico = normcols(dico);
+    end
+    
+    switch lower(DL.param.decFcn)
+        case 'ink-svd'
+            dico = dico_decorr_symetric(dico,mu,solver.solution);
+        case 'grassmannian'
+            [n m] = size(dico);
+            dico = grassmannian(n,m,[],0.9,0.99,dico);
+        case 'shrinkgram'
+            dico = shrinkgram(dico,mu);
+        case 'iterproj'
+            dico = iterativeprojections(dico,mu,Problem.b1,solver.solution);
+        otherwise
+    end
+    
\ No newline at end of file
--- a/extra/README.txt	Thu Feb 09 17:26:45 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-
-SMALLbox Version 2.0 alpha
-
-7 February, 2012
-
-Version 1.0 beta of SMALLbox is the release candidate that is distributed 
-for testing and bug fixing purposes. Please send all bugs, requests and suggestions to:
-
-luis.figueira@eecs.qmul.ac.uk
-
-
----------------------------------------------------------------------------
-
-Copyright (2010): 	Ivan Damnjanovic, Matthew Davies
-			Centre for Digital Music, 
-			Queen Mary University of London
-
-SMALLbox is distributed under the terms of the GNU General Public License 3
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
----------------------------------------------------------------------------
-
-This folder is where all external toolboxes, examples, plugins, etc should be put.
\ No newline at end of file
--- a/util/SMALL_learn.m	Thu Feb 09 17:26:45 2012 +0000
+++ b/util/SMALL_learn.m	Tue Mar 13 17:33:20 2012 +0000
@@ -23,88 +23,10 @@
 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')
+  % configuration file
+  run([SMALL_path 'config/SMALL_learn_config.m']);
     
-    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; 
-    
-%   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>);']);
-
-  else
-    printf('\nToolbox has not been registered. Please change SMALL_learn file.\n');
-    return
-  end
-  
 %%
 %   Dictionary Learning time
 tElapsed=toc(tStart);