function snmf
%
V1=double(imread('E:\multal model\data\IMG_1089.JPG'));
V=V1(:,:,1);
rdim=500;
alpha=0.2;
showflag=1;
fname='lfl';
% Check that we have non-negative data
if min(V(:))<0, error('Negative values in data!'); end
% Globally rescale data to avoid potential overflow/underflow
V = V/max(V(:));
% Dimensions
vdim = size(V,1);
samples = size(V,2);
% Create initial matrices
W = abs(randn(vdim,rdim));
H = abs(randn(rdim,samples));
% Make sure W has unit sum columns!
W = W./(ones(vdim,1)*sum(W,1));
% Initialize displays
if showflag,
figure(1); clf; % this will show the energies and sparsenesses
figure(2); clf; % this will show the objective function
drawnow;
end
% Calculate initial objective
objhistory = sum(sum((V.*log(V./(W*H))) - V + W*H)) + alpha*sum(sum(H));
timestarted = clock;
% Start iteration
iter = 0;
while 1,
% Show progress
fprintf('[%d]: %.5f \n',iter,objhistory(end));
% Save every once in a while
if rem(iter,5)==0,
elapsed = etime(clock,timestarted);
fprintf('Saving...');
save(fname,'W','H','alpha','iter','objhistory','elapsed');
fprintf('Done!\n');
end
% Show stats
if showflag & (rem(iter,5)==0),
figure(1);
cursW = (sqrt(vdim)-(sum(W)./sqrt(sum(W.^2))))/(sqrt(vdim)-1);
cursH = (sqrt(samples)-(sum(H')./sqrt(sum(H'.^2))))/(sqrt(samples)-1);
subplot(3,1,1); bar(sqrt(sum(W.^2)).*sqrt(sum(H'.^2)));
subplot(3,1,2); bar(cursW);
subplot(3,1,3); bar(cursH);
if iter>1,
figure(2);
plot(objhistory(2:end));
end
drawnow;
end
% Update iteration count
iter = iter+1;
% Save old values
Wold = W;
Hold = H;
% Update H with multiplicative step
H = (H.*(W'*(V./(W*H))))/(1+alpha);
% This update is the same as Lee and Seung's divergence step
W = W.*((V./(W*H))*H')./(ones(vdim,1)*sum(H'));
% Liu, Zheng, and Lu add this normalization step
W = W./(ones(vdim,1)*sum(W));
% Calculate objective
newobj = sum(sum((V.*log(V./(W*H))) - V + W*H)) + alpha*sum(sum(H));
objhistory = [objhistory newobj];
end
end
snmf.rar_jpg_matlab video_snmf
版权申诉
19 浏览量
2022-09-20
10:46:55
上传
评论
收藏 1KB RAR 举报
Kinonoyomeo
- 粉丝: 77
- 资源: 1万+
最新资源
- SQL语言优质学习资源工具与案列应用场景开发文档.txt
- PHP语言优质学习资源和工具与案列应用场景和开发文档.txt
- go语言优质学习资源和工具与案列应用场景.txt
- 23957825633dCar.zip
- Ruby优质学习资源和工具与案列应用场景.txt
- 阿里巴巴大数据实践之路-陈鹏宇(PDF格式).rar
- 基于医疗知识图谱的智能问答系统python实现源码+使用教程(毕业设计).zip
- 基于Python实现的医疗知识图谱的知识问答系统源码+使用教程(毕业设计).zip
- Objective-C优质学习资源和工具与案列应用场景.txt
- 基于python知识图谱医疗领域问答系统实现完整源码+使用说明(毕业设计).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈