循环神经网络
matlab 低秩矩阵分解,低秩分解的matlab代码看不懂,分解的两个矩阵在哪呀??... -凯发ag旗舰厅登录网址下载
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
有四个文件:demo.m
function [] = demo()
%this routine demonstrates an example of using lrr to do subspace segmentation. we cosntruct 5 independent subspaces, each of which has a rank of 10,
%sample 200 points of dimension 100 from each subspae, and randomly choose some points to corrupt.
[x,cids] = generate_data();
ls = [0.0001 0.0005 0.001 0.002 0.004 0.008 0.01 0.02 0.04 0.08 0.1]; %parameter lambda
rs = [];
accs=[];
for i=1:length(ls)
z = solve_lrr(x,x,ls(i));
l = abs(z) abs(z');
disp('perfoming ncut ...');
idx = clu_ncut(l,5);
acc = compacc(idx,cids);
disp(['lambda=' num2str(ls(i)) ',seg acc=' num2str(acc)]);
rs = [rs,rank(z,1e-3*norm(z,2))];
accs = [accs,acc];
end
close all;
figure;
subplot(1,2,1);
plot(ls,accs);
xlabel('parameter \lambda');
ylabel('segmentation accuracy');
subplot(1,2,2);
plot(ls,rs);
xlabel('parameter \lambda');
ylabel('rank(z)');
function [x,cids] = generate_data()
n = 200;
d = 10;
d = 100;
[u,s,v] = svd(rand(d));
cids = [];
u1 = u(:,1:d);
x = u1*rand(d,n);
cids = [cids,ones(1,n)];
for i=2:5
r = orth(rand(d));
u1 = r*u1;
x = [x,u1*rand(d,n)];
cids = [cids,i*ones(1,n)];
end
nx = size(x,2);
norm_x = sqrt(sum(x.^2,1));
norm_x = repmat(norm_x,d,1);
gn = norm_x.*randn(d,nx);
inds = rand(1,nx)<=0.3;
x(:,inds) = x(:,inds) 0.3*gn(:,inds);
function [idx] = clu_ncut(l,k)
l = (l l')/2;
d = diag(1./sqrt(sum(l,2)));
l = d*l*d;
[u,s,v] = svd(l);
v = u(:,1:k);
v = d*v;
idx = kmeans(v,k,'emptyaction','singleton','replicates',10,'display','off');
idx = idx';
function [acc] = compacc(segmentation,refsegmentation)
ngroups = length(unique(refsegmentation));
if(size(refsegmentation,2)==1)
refsegmentation=refsegmentation';
end
if(size(segmentation,2)==1)
segmentation=segmentation';
end
permutations = perms(1:ngroups);
miss = zeros(size(permutations,1),size(segmentation,1));
for k=1:size(segmentation,1)
for j=1:size(permutations,1)
miss(j,k) = sum(abs(segmentation(k,:)-permutations(j,refsegmentation))>0.1);
end
end
[miss,temp] = min(miss,[],1);
acc = 1 - miss/length(segmentation);
总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的matlab 低秩矩阵分解,低秩分解的matlab代码看不懂,分解的两个矩阵在哪呀??...的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇: matlab cameraman,cam
- 下一篇: gps数据处理matlab,基于matl