This commit is contained in:
2017-05-28 06:51:50 +09:00
parent c3211f4b66
commit de9c69bae6
5 changed files with 32 additions and 15 deletions

View File

@@ -36,10 +36,11 @@ grad = zeros(size(theta));
% grad = grad + YOUR_CODE_HERE (using the temp variable)
%
hx = sigmoid(X*theta);
%J = sum(-y.*log(hx)-(1.-y).*log(1.-hx))/m + lambda*sum([0; theta(2:end)].^2)/(2*m);
J = (-y'*log(hx)-(1.-y)'*log(1.-hx))/m + lambda*sum([0; theta(2:end)].^2)/(2*m);
grad = X'*(hx-y)/m + lambda*[0; theta(2:end)]/m;