comparison util/SMALL_learn.m @ 121:5ded5e2e7d07 ivand_dev

bug 159 Removed API for Skretting/Engang rlsdla
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Wed, 25 May 2011 13:33:47 +0100
parents f6cc633fd94b
children 485747bf39e0
comparison
equal deleted inserted replaced
110:850e90bbf4b0 121:5ded5e2e7d07
1 function DL = SMALL_learn(Problem,DL) 1 function DL = SMALL_learn(Problem,DL)
2 %%% SMALL Dictionary Learning 2 %% SMALL Dictionary Learning
3 %
4 % Function gets as input Problem and Dictionary Learning (DL) structures
5 % In Problem structure field b with the training set needs to be defined
6 % In DL fields with name of the toolbox and solver, and parameters file
7 % for particular dictionary learning technique needs to be present.
8 %
9 % Outputs are Learned dictionary and time spent as a part of DL structure
10
3 % 11 %
4 % Centre for Digital Music, Queen Mary, University of London. 12 % Centre for Digital Music, Queen Mary, University of London.
5 % This file copyright 2009 Ivan Damnjanovic. 13 % This file copyright 2009 Ivan Damnjanovic.
6 % 14 %
7 % This program is free software; you can redistribute it and/or 15 % This program is free software; you can redistribute it and/or
8 % modify it under the terms of the GNU General Public License as 16 % modify it under the terms of the GNU General Public License as
9 % published by the Free Software Foundation; either version 2 of the 17 % published by the Free Software Foundation; either version 2 of the
10 % License, or (at your option) any later version. See the file 18 % License, or (at your option) any later version. See the file
11 % COPYING included with this distribution for more information. 19 % COPYING included with this distribution for more information.
12 %
13 % Function gets as input Problem and Dictionary Learning (DL) structures
14 % In Problem structure field b with the training set needs to be defined
15 % In DL fields with name of the toolbox and solver, and parameters file
16 % for particular dictionary learning technique needs to be present.
17 %
18 % Outputs are Learned dictionary and time spent as a part of DL structure
19 %% 20 %%
20 21
21 fprintf('\nStarting Dictionary Learning %s... \n', DL.name); 22 fprintf('\nStarting Dictionary Learning %s... \n', DL.name);
22 start=cputime; 23 start=cputime;
23 tStart=tic; 24 tStart=tic;
54 % unit lenght. 55 % unit lenght.
55 56
56 for i = 1: size(D,2) 57 for i = 1: size(D,2)
57 D(:,i)=D(:,i)/norm(D(:,i)); 58 D(:,i)=D(:,i)/norm(D(:,i));
58 end 59 end
59 elseif strcmpi(DL.toolbox,'mpv2') 60
60 X = Problem.b(:,1:1:40000);
61 jD0 = mpv2.SimpleMatrix(DL.param.D);
62 jDicLea = mpv2.DictionaryLearning(jD0, 1,1);
63 % !!!!! MAYBE lambda is not needed for ILS - NEED TO CHECK!!!!
64 jDicLea.setLambda('L', DL.param.lambda, DL.param.lambda, 1000);
65 jDicLea.setVerbose(2);
66 jDicLea.setORMP(16, 1e-6, DL.param.abs);
67 eval(['jDicLea.',DL.name,'( X(:), DL.param.iternum );']);
68 jD = jDicLea.getDictionary();
69
70 D = reshape(jD.getAll(), size(X,1), DL.param.K);
71
72 % To introduce new dictionary learning technique put the files in 61 % To introduce new dictionary learning technique put the files in
73 % your Matlab path. Next, unique name <TolboxID> for your toolbox needs 62 % your Matlab path. Next, unique name <TolboxID> for your toolbox needs
74 % to be defined and also prefferd API for toolbox functions <Preffered_API> 63 % to be defined and also prefferd API for toolbox functions <Preffered_API>
75 % 64 %
76 % elseif strcmpi(DL.toolbox,'<ToolboxID>') 65 % elseif strcmpi(DL.toolbox,'<ToolboxID>')