结果未达到θ值的预期

时间:2017-08-04 03:23:29

标签: matlab gradient-descent

m = length(y); % number of training examples
J_history = zeros(num_iters, 1);

for iter = 1:num_iters

    J_history(iter) = computeCost(X, y, theta);
    h=sum(X*theta-y);
    H=sum((X*theta-y).*X(:,2));
    a=theta(1)-(alpha/num_iters)*h;
    b=theta(2)-(alpha/num_iters)*H;
    theta=[a;b];    
end

0 个答案:

没有答案