Mercurial > hg > smallbox
diff DL/two-step DL/SMALL_two_step_DL.m @ 153:af307f247ac7 ivand_dev
Example scripts for Two Step Dictionary Learning - Image Denoising experiments.
author | Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Fri, 29 Jul 2011 12:35:52 +0100 |
parents | 485747bf39e0 |
children | a4d0977d4595 759313488e7b |
line wrap: on
line diff
--- a/DL/two-step DL/SMALL_two_step_DL.m Thu Jul 28 15:49:32 2011 +0100 +++ b/DL/two-step DL/SMALL_two_step_DL.m Fri Jul 29 12:35:52 2011 +0100 @@ -85,7 +85,7 @@ % show dictonary every specified number of iterations -if (isfield(DL.param,'show_dict')) +if isfield(DL.param,'show_dict') show_dictionary=1; show_iter=DL.param.show_dict; else @@ -100,19 +100,22 @@ tmpTraining = Problem.b1; Problem.b1 = sig; -Problem = rmfield(Problem, 'reconstruct'); +if isfield(Problem,'reconstruct') + Problem = rmfield(Problem, 'reconstruct'); +end solver.profile = 0; % main loop % 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 - Problem.A = dico; + if ((show_dictionary)&&(mod(i,show_iter)==0)) dictimg = SMALL_showdict(dico,[8 8],... round(sqrt(size(dico,2))),round(sqrt(size(dico,2))),'lines','highcontrast'); @@ -124,4 +127,16 @@ Problem.b1 = tmpTraining; DL.D = dico; +end + +function Y = colnorms_squared(X) + +% compute in blocks to conserve memory +Y = zeros(1,size(X,2)); +blocksize = 2000; +for i = 1:blocksize:size(X,2) + blockids = i : min(i+blocksize-1,size(X,2)); + Y(blockids) = sum(X(:,blockids).^2); +end + end \ No newline at end of file