From 31c4ac1967de8a86996c90efbb5b6bf1a1ce03df Mon Sep 17 00:00:00 2001 From: neingeist Date: Tue, 14 Oct 2014 07:46:10 +0200 Subject: [PATCH] Compute the gradient for logistic regression --- ex2/costFunction.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ex2/costFunction.m b/ex2/costFunction.m index 1f49581..017299c 100644 --- a/ex2/costFunction.m +++ b/ex2/costFunction.m @@ -21,7 +21,7 @@ grad = zeros(size(theta)); % J = 1/m * (-y'*log(sigmoid(X*theta)) - (1-y)'*log(1-sigmoid(X*theta))); - +grad = 1/m * X' * (sigmoid(X*theta) - y);