我正在并行运行我的代码,我的本地配置文件有两个核心。此代码是隐马尔可夫模型中的前向算法。我的代码在这里:
function [ eln_alpha ] = forward_algo( Obs,P,Pi_0 ,Q )
parpool('local',2);
n = length(Pi_0);
T = length(Obs);
eln_alpha = zeros(n,T,'distributed');
parfor i1=1:n
eln_alpha(i1,1) = elnproduct( eln(Pi_0(i1)) , eln(Q(i1,1)) );
end;
fi = T / numlabs;
P ;
spmd % =================>>> line 45
if labindex == 1
labSend(P, 2);
labSend(Q, 2);
end
if labindex == 2
P = labReceive(1);
Q = labReceive(1);
end
for t = ((labindex-1)*fi)+1:(labindex * fi)
if t==1
t=t+1;
end
for j=1:n
logalpha = NaN;
for i1=1:n
logalpha = elnsum(logalpha , elnproduct( eln_alpha(i1,t-1) ,eln(P(i1,j)) ) );
end;
eln_alpha(j,t) = elnproduct(logalpha , eln( Q(j,t) ));
end;
end
end
end
and的结果elnsum
和只是类型中的一个值。elnproduct
eln
double
我得到这个错误:
使用 forward_algo>(spmd) 时出错(第 45 行)
在工作人员 1 上检测到
错误 2. forward_algo 中的错误(第 45 行)spmdCaused by: Error using codistributed/subsasgn (line 131) Assignment has more non-singleton rhs dimensions than non-singleton subscripts Error using codistributed/subsasgn (line 131) Assignment has more non-singleton rhs dimensions than non-singleton subscripts
看起来我并没有尝试将多个值分配到一个左手位置以导致Assignment has more non-singleton rhs dimensions than non-singleton subscripts
错误。有人可以帮忙吗?
谢谢你