This commit is contained in:
2017-05-28 20:20:47 +09:00
parent 4620fe8652
commit a1fda7be43
6 changed files with 41 additions and 17 deletions

View File

@@ -21,8 +21,9 @@ grad = zeros(size(theta));
hx = X*theta;
J = sum((hx - y).**2)/(2*m) + lambda*sum((theta(2:end).**2))/(2*m);
grad = (sum((hx-y).*X)/m)' + lambda*[0; theta(2:end)]/m;