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 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by