function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
m = length(y);
J_history = zeros(num_iters, 1);
for iter = 1:num_iters
## warning: product: automatic broadcasting operation applied
theta = theta - sum(X .* (X * theta - y))' .* (alpha / (m .* 2));
J_history(iter) = computeCost(X, y, theta);
end
end
这是我的作业,但我并不要求你替我完成(实际上我认为我已经完成了或接近完成)。我已经阅读了手册中有关广播的部分,但我仍然不明白为什么我在这里收到了警告?
注:broadcasting指的是在numpy数组上执行算术运算时的一种特殊机制。