Mercurial > hg > smallbox
comparison util/classes/dictionaryMatrices/rotatematrix.m @ 184:8fc38e8df8c6 danieleb
Minor edits
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Fri, 27 Jan 2012 13:18:50 +0000 |
parents | 9c41f87dead7 |
children |
comparison
equal
deleted
inserted
replaced
183:0d7a81655ef2 | 184:8fc38e8df8c6 |
---|---|
1 function [Dhat cost W] = rotatematrix(D,Phi,method,param) | 1 function [Dhat cost W] = rotatematrix(D,Phi,method,param) |
2 % | 2 % |
3 % | 3 % |
4 % | 4 % |
5 % REFERENCE | 5 % REFERENCE |
6 % M.D. Plumbley, Geometrical Methods for Non-Negative ICA: Manifolds, Lie | 6 % M.D. Plumbley, Geometrical Methods for Non-Negative ICA: Manifolds, Lie |
7 % Groups and Toral Subalgebra, Neurocomputing | 7 % Groups and Toral Subalgebra, Neurocomputing |
88 n = 256; %ambient dimension | 88 n = 256; %ambient dimension |
89 m = 512; %number of atoms | 89 m = 512; %number of atoms |
90 param.nIter = 300; %number of iterations | 90 param.nIter = 300; %number of iterations |
91 param.step = 0.001; %step size | 91 param.step = 0.001; %step size |
92 param.mu = 0.01; %regularization factor (for tangent method) | 92 param.mu = 0.01; %regularization factor (for tangent method) |
93 methods = {'unconstrained','tangent','linesearchlie','conjgradlie'}; | 93 methods = {'tangent','linesearchlie','conjgradlie'}; |
94 | 94 |
95 Phi = randn(n,m); %initial dictionary | 95 Phi = randn(n,m); %initial dictionary |
96 Qtrue = expm(skew(randn(n))); %rotation matrix | 96 Qtrue = expm(skew(randn(n))); %rotation matrix |
97 D = Qtrue*Phi; %target dictionary | 97 D = Qtrue*Phi; %target dictionary |
98 | 98 |
99 cost = zeros(param.nIter,length(methods)); | 99 cost = zeros(param.nIter,length(methods)); |
100 times = zeros(param.nIter,length(methods)); | |
100 for iIter=1:length(methods) | 101 for iIter=1:length(methods) |
101 tic | 102 tic |
102 [~, cost(:,iIter)] = rotatematrix(D,Phi,methods{iIter},param); | 103 [~, cost(:,iIter)] = rotatematrix(D,Phi,methods{iIter},param); |
103 time = toc; | 104 times(:,iIter) = linspace(0,toc,param.nIter); |
104 sprintf('Method %s completed in %f seconds \n',methods{iIter},time) | 105 sprintf('Method %s completed in %f seconds \n',methods{iIter},toc) |
105 end | 106 end |
106 | 107 |
107 figure, plot(cost) | 108 figure, plot(times,cost) |
108 set(gca,'XScale','log','Yscale','log') | 109 set(gca,'XScale','lin','Yscale','log') |
109 legend(methods) | 110 legend(methods) |
110 grid on | 111 grid on |
111 xlabel('number of iterations') | 112 xlabel('time (sec)') |
112 ylabel('J(W)') | 113 ylabel('J(W)') |
113 end | 114 end |