Guest User

Untitled

a guest
Feb 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.22 KB | None | 0 0
  1. h = sigmoid(X * theta);
  2. f = -y.*log(h);
  3. s = (1-y).*log(1-h);
  4. J = (f-s);
  5. grad = X'*(h - y);
  6. b = lambda/(2*m);
  7. c = theta .^ 2;
  8. J = a*sum(J)+b*sum(c);
  9. temp = theta;
  10. temp(1) = 0;
  11. grad = a*sum(grad) + sum(temp*lambda);
Add Comment
Please, Sign In to add comment