mirror of
https://github.com/jlengrand/MachineLearningCoursera.git
synced 2026-03-10 08:31:20 +00:00
Implements gradientDescent.
End of the mandatory assignment.
This commit is contained in:
@@ -16,12 +16,16 @@ for iter = 1:num_iters
|
||||
% Hint: While debugging, it can be useful to print out the values
|
||||
% of the cost function (computeCost) and gradient here.
|
||||
%
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
tmat = repmat( theta, 1, size(X, 1) );
|
||||
h_theta = tmat' .* X;
|
||||
to_sum = (sum(h_theta,2) - y);
|
||||
|
||||
to_sum_1 = to_sum .* X(:, 1);
|
||||
to_sum_2 = to_sum .* X(:, 2);
|
||||
|
||||
theta(1) = theta(1) - (alpha * (1/m) * sum(to_sum_1));
|
||||
theta(2) = theta(2) - (alpha * (1/m) * sum(to_sum_2));
|
||||
|
||||
% ============================================================
|
||||
|
||||
|
||||
BIN
W2/machine-learning-ex1/ex1/token.mat
Normal file
BIN
W2/machine-learning-ex1/ex1/token.mat
Normal file
Binary file not shown.
Reference in New Issue
Block a user