Mercurial > hg > smallbox
comparison util/SMALL_learn.m @ 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 | b14209313ba4 |
children | d50f5bdbe14c |
comparison
equal
deleted
inserted
replaced
187:3cc204120431 | 190:759313488e7b |
---|---|
21 if (DL.profile) | 21 if (DL.profile) |
22 fprintf('\nStarting Dictionary Learning %s... \n', DL.name); | 22 fprintf('\nStarting Dictionary Learning %s... \n', DL.name); |
23 end | 23 end |
24 start=cputime; | 24 start=cputime; |
25 tStart=tic; | 25 tStart=tic; |
26 if strcmpi(DL.toolbox,'KSVD') | |
27 param=DL.param; | |
28 param.data=Problem.b; | |
29 | |
30 D = eval([DL.name,'(param)']);%, ''t'', 5);']); | |
31 elseif strcmpi(DL.toolbox,'KSVDS') | |
32 param=DL.param; | |
33 param.data=Problem.b; | |
34 | 26 |
35 D = eval([DL.name,'(param, ''t'', 5);']); | 27 % configuration file |
36 elseif strcmpi(DL.toolbox,'SPAMS') | 28 run([SMALL_path 'config/SMALL_learn_config.m']); |
37 | 29 |
38 X = Problem.b; | |
39 param=DL.param; | |
40 | |
41 D = eval([DL.name,'(X, param);']); | |
42 % As some versions of SPAMS does not produce unit norm column | |
43 % dictionaries, we need to make sure that columns are normalised to | |
44 % unit lenght. | |
45 | |
46 for i = 1: size(D,2) | |
47 D(:,i)=D(:,i)/norm(D(:,i)); | |
48 end | |
49 elseif strcmpi(DL.toolbox,'SMALL') | |
50 | |
51 X = Problem.b; | |
52 param=DL.param; | |
53 | |
54 D = eval([DL.name,'(X, param);']); | |
55 % we need to make sure that columns are normalised to | |
56 % unit lenght. | |
57 | |
58 for i = 1: size(D,2) | |
59 D(:,i)=D(:,i)/norm(D(:,i)); | |
60 end | |
61 | |
62 elseif strcmpi(DL.toolbox,'TwoStepDL') | |
63 | |
64 DL=SMALL_two_step_DL(Problem, DL); | |
65 | |
66 % we need to make sure that columns are normalised to | |
67 % unit lenght. | |
68 | |
69 for i = 1: size(DL.D,2) | |
70 DL.D(:,i)=DL.D(:,i)/norm(DL.D(:,i)); | |
71 end | |
72 D = DL.D; | |
73 | |
74 elseif strcmpi(DL.toolbox,'MMbox') | |
75 | |
76 DL = wrapper_mm_DL(Problem, DL); | |
77 | |
78 % we need to make sure that columns are normalised to | |
79 % unit lenght. | |
80 | |
81 for i = 1: size(DL.D,2) | |
82 DL.D(:,i)=DL.D(:,i)/norm(DL.D(:,i)); | |
83 end | |
84 D = DL.D; | |
85 | |
86 % To introduce new dictionary learning technique put the files in | |
87 % your Matlab path. Next, unique name <TolboxID> for your toolbox needs | |
88 % to be defined and also prefferd API for toolbox functions <Preffered_API> | |
89 % | |
90 % elseif strcmpi(DL.toolbox,'<ToolboxID>') | |
91 % % This is an example of API that can be used: | |
92 % % - get training set from Problem part of structure | |
93 % % - assign parameters defined in the main program | |
94 % | |
95 % X = Problem.b; | |
96 % param=DL.param; | |
97 % | |
98 % % - Evaluate the function (DL.name - defined in the main) with | |
99 % % parameters given above | |
100 % | |
101 % D = eval([DL.name,'(<Preffered_API>);']); | |
102 | |
103 else | |
104 printf('\nToolbox has not been registered. Please change SMALL_learn file.\n'); | |
105 return | |
106 end | |
107 | |
108 %% | 30 %% |
109 % Dictionary Learning time | 31 % Dictionary Learning time |
110 tElapsed=toc(tStart); | 32 tElapsed=toc(tStart); |
111 DL.time = cputime - start; | 33 DL.time = cputime - start; |
112 if (DL.profile) | 34 if (DL.profile) |