欢迎访问 生活随笔!

凯发k8官方网

当前位置: 凯发k8官方网 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab 低秩矩阵分解,低秩分解的matlab代码看不懂,分解的两个矩阵在哪呀??... -凯发k8官方网

发布时间:2024/10/14 循环神经网络 25 豆豆
凯发k8官方网 收集整理的这篇文章主要介绍了 matlab 低秩矩阵分解,低秩分解的matlab代码看不懂,分解的两个矩阵在哪呀??... 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

有四个文件: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);

总结

以上是凯发k8官方网为你收集整理的matlab 低秩矩阵分解,低秩分解的matlab代码看不懂,分解的两个矩阵在哪呀??...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得凯发k8官方网网站内容还不错,欢迎将凯发k8官方网推荐给好友。

网站地图