function [W,H] = nmf(V,Winit,Hinit,tol,timelimit,maxiter)
% NMF by alternative non-negative least squares using projected gradients
% Author: Chih-Jen Lin, National Taiwan University
% W,H: output solution 输出结果
first name% Winit,Hinit: initial solution
% tol: tolerance for a relative stopping condition
% timelimit, maxiter: limit of time and iterations
西餐礼仪英语>epoch>英文书名W = Winit; H = Hinit; initt = cputime;
gradW = W*(H*H’) - V*H’;
gradH = (W’*W)*H - W’*V;
contaxinitgrad = norm([gradW; gradH’],’fro’);
fireball
fprintf(’Init gradient norm %f\n’, initgrad);
tolW = max(0.001,tol)*initgrad; tolH = tolW;
for iter=1:maxiter,
% stopping condition工商行政管理局英文
projnorm = norm([gradW(gradW<0 | W>0); gradH(gradH<0 | H>0)]);
if projnorm < tol*initgrad | cputime-initt > timelimit,
break;
endblur
[W,gradW,iterW] = nlssub prob(V’,H’,W’,tolW,1000); W = W’; gradW = gradW’; if iterW==1,
tolW = 0.1 * tolW;
end
[H,gradH,iterH] = nlssubprob(V,W,H,tolH,1000);slideunlock
if iterH==1,
tolH = 0.1 * tolH;
end
小升初英语
if rem(iter,10)==0, fprintf(’.’); end
end
fprintf(’\nIter = %d Final proj-grad norm %f\n’, iter, projnorm);