Error using parfor: cannot use parfor because of the way Theta/nk is used
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everyone, I am using a very old version of Xeon PC to run a gaussian mixture model using Dirichlet process and Gibb's sampling on a Big Data. I hoped I could speed it up using parfor commands but was unable to do it becuase of the error!!
n = size(X,2);
Theta = {};
nk = [];
label = zeros(1,n);
llh = 0;
for i = randperm(n)
x = X(:,i);
Pk = log(nk)+cellfun(@(t) t.logPredPdf(x), Theta);
P0 = log(alpha)+theta.logPredPdf(x);
p = [Pk,P0];
llh = llh+sum(p-log(n));
k = discreteRnd(exp(p-logsumexp(p)));
if k == numel(Theta)+1
Theta{k} = theta.clone().addSample(x);
nk = [nk,1];
else
Theta{k} = Theta{k}.addSample(x);
nk(k) = nk(k)+1;
end
label(i) = k;
end
w = nk/n;
Please note that the first function I used above provided faster results so, I am not worried about it very much.
Thanks and Regards in advance.
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!