- #1
jiaying
- 1
- 0
Hey,for following code the 3rd loops i need to have 2 variables m and q .Could anyone help?
Matlab:
for t=1:maxiterations
toterror=0;
for j=1:numfeature
totslope=0;
for i=1:m&&q=1:numfeature
z=0;
for jj=1:numfeature
z=z+prevtheta(jj)*x(i,jj);
end
h=1.0/(1.0+exp(-z));
H=H+(x(i,q)*h*(1-h)*x(i,jj));
totslope=(totslope+(h-y(i))*x(i,j));
toterror=(toterror+-y(i)*log(h)-(1-y(i))*log(1-h));
end
toterror=toterror/numtrainsam;
theta(j)= theta(j)-H\totslope;
end
prevtheta=theta;
errorperiteration(t)=toterror/j;
end
Last edited by a moderator: