Skip to content

Commit

Permalink
Gradient with regularization
Browse files Browse the repository at this point in the history
  • Loading branch information
Merouane Atig committed Dec 12, 2011
1 parent 1f24902 commit 2d4ad88
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mlclass-ex8/cofiCostFunc.m
Expand Up @@ -46,14 +46,14 @@
idx = find(R(i, :) == 1);
Theta_temp = Theta(idx, :);
Y_temp = Y(i, idx);
X_grad(i, :) = (X(i, :) * Theta_temp' - Y_temp) * Theta_temp;
X_grad(i, :) = (X(i, :) * Theta_temp' - Y_temp) * Theta_temp + lambda * X(i, :);
end

for i=1:num_users
idx = find(R(:, i) == 1);
X_temp = X(idx, :);
Y_temp = Y(idx, i);
Theta_grad(i, :) = (X_temp * Theta(i, :)' - Y_temp)' * X_temp;
Theta_grad(i, :) = (X_temp * Theta(i, :)' - Y_temp)' * X_temp + lambda * Theta(i, :);
end

% =============================================================
Expand Down

0 comments on commit 2d4ad88

Please sign in to comment.