Я делаю ML от Cousera, и это создает ошибку для линейного регрессионного задания, и я не понимаю, в чем проблема. Я использую октаву 4.0 на окнах 10. Вот код:Ошибка октавной петли
function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
m = length(y); % number of training examples
hypo = [m,1];
J_history = zeros(num_iters, 1);
for iter = 1: num_iters
% ====================== YOUR CODE HERE ======================
% Instructions: Perform a single gradient step on the parameter vector
% theta.
%
% Hint: While debugging, it can be useful to print out the values
% of the cost function (computeCost) and gradient here.
%
hypo = theta(1) + theta(2) * X;
temp1 = theta(1) - alpha * (1/m) * sum(hypo);
hypo = theta(1) + theta(2) * X;
temp2 = theta(2) - alpha * (1/m) * sum((hypo .* X));
theta = [temp1; temp2];
% ===========================================================
% Save the cost J in every iteration
J_history(iter) = computeCost(X, y, theta);
end
predict1 = [1, 3.5] * theta;
predict2 = [1, 7.0] * theta;
end
это производит циклическую ошибку "A (I) = X: X такого же размера, как я" в
J_history(iters) = computeCost(X, y, theta);
Что возвращает 'computeCost'? – beaker
Я думаю, вы имеете в виду matlab, а не [ML] (https://en.wikipedia.org/wiki/ML_%28programming_language%29). – carandraug
@ carandraug no Я думаю, что coursera на самом деле предлагает [Maching Learning course] (https://www.coursera.org/learn/machine-learning), и главный инструктор (Andrew Ng), похоже, рекомендует Octave от того, что у меня есть слышал. (Woo! \ O /). Я видел несколько человек за последние пару недель, указав, что они только что установили Octave, потому что они делают курс Andrew Ng :) –