Skip to content

Instantly share code, notes, and snippets.

@martinthenext
Created November 6, 2011 21:33
Show Gist options
  • Save martinthenext/1343532 to your computer and use it in GitHub Desktop.
Save martinthenext/1343532 to your computer and use it in GitHub Desktop.
J = 1 / m * (sum(-1 * y .* log(sigmoid(X * theta)) - (1 - y) .* log(sigmoid(X * theta)))) + lambda / (2 * m) * sum(theta(2:length(theta),:));
grad = 1 / m * X' * (sigmoid(X * theta) - y);
temp = theta;
temp(1) = 0;
grad = grad + (lambda / m) * temp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment