Skip to content

Instantly share code, notes, and snippets.

@dmichael
Created November 13, 2011 16:11
Show Gist options
  • Select an option

  • Save dmichael/1362267 to your computer and use it in GitHub Desktop.

Select an option

Save dmichael/1362267 to your computer and use it in GitHub Desktop.
Neural Network Regularized Cost Function
regularization = lambda/(2*m) * ( ...
sum(sum((Theta1(:,2:end)).^2)) + ...
sum(sum((Theta2(:,2:end)).^2)) ...
);
J = (1/m) * sum( ...
sum((-y .* log(h))-((1-y) .* log(1-h))) ...
);
J = J + regularization;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment