idamnjanovic@8: function DL = SMALL_learn(Problem,DL) luis@199: %% SMALL Dictionary Learning luis@199: % luis@199: % Function gets as input Problem and Dictionary Learning (DL) structures ivan@121: % In Problem structure field b with the training set needs to be defined luis@199: % In DL fields with name of the toolbox and solver, and parameters file ivan@121: % for particular dictionary learning technique needs to be present. ivan@121: % ivan@121: % Outputs are Learned dictionary and time spent as a part of DL structure ivan@121: idamnjanovic@24: % idamnjanovic@24: % Centre for Digital Music, Queen Mary, University of London. idamnjanovic@24: % This file copyright 2009 Ivan Damnjanovic. idamnjanovic@24: % idamnjanovic@24: % This program is free software; you can redistribute it and/or idamnjanovic@24: % modify it under the terms of the GNU General Public License as idamnjanovic@24: % published by the Free Software Foundation; either version 2 of the idamnjanovic@24: % License, or (at your option) any later version. See the file idamnjanovic@24: % COPYING included with this distribution for more information. idamnjanovic@8: %% luis@199: luis@216: SMALLboxInit luis@203: ivan@152: if (DL.profile) luis@199: fprintf('\nStarting Dictionary Learning %s... \n', DL.name); ivan@152: end luis@199: luis@199: start=cputime; luis@199: tStart=tic; luis@199: luis@228: %% toolbox configuration luis@228: % test if there is a locally modified version of the config luis@228: % otherwise reads the "default" config file luis@228: if exist(fullfile(SMALL_path, 'config/SMALL_learn_config_local.m'), 'file') == 2 luis@228: printf('\n\nSMALL_learn: Using local configuration file.\n\n'); luis@228: run(fullfile(SMALL_path, 'config/SMALL_learn_config_local.m')); luis@228: else luis@228: printf('\n\nSMALL_learn: Using default configuration file.\n\n'); luis@228: run(fullfile(SMALL_path, 'config/SMALL_learn_config.m')); luis@228: end luis@199: idamnjanovic@8: %% idamnjanovic@8: % Dictionary Learning time idamnjanovic@36: tElapsed=toc(tStart); ivan@152: DL.time = cputime - start; ivan@152: if (DL.profile) luis@199: fprintf('\n%s finished task in %2f seconds (cpu time). \n', DL.name, DL.time); luis@199: fprintf('\n%s finished task in %2f seconds (tic-toc time). \n', DL.name, tElapsed); ivan@152: end idamnjanovic@36: DL.time=tElapsed; luis@199: % If dictionary is given as a sparse matrix change it to full idamnjanovic@8: luis@199: DL.D = full(D); luis@199: idamnjanovic@8: end luis@199: