Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions exercises/mlclass-ex1/gradientDescent.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
% Initialize some useful values
m = length(y); % number of training examples
J_history = zeros(num_iters, 1);
num_vars=size(X,2);

for iter = 1:num_iters

Expand All @@ -17,11 +16,7 @@
% Hint: While debugging, it can be useful to print out the values
% of the cost function (computeCost) and gradient here.
%
theta_tmp=zeros(num_vars,1);
for j=1:num_vars
theta_tmp(j)= theta(j) - (alpha/m) * sum(((X*theta)-y).*X(:,j));
end
theta=theta_tmp;
theta = theta - (X' * (X * theta - y) * alpha / m);
% ============================================================

% Save the cost J in every iteration
Expand Down