From 30262a84225ad3d7dd3476cef98b12bfffe4530f Mon Sep 17 00:00:00 2001 From: Joel Lowery Date: Fri, 14 Apr 2017 00:11:40 -0500 Subject: [PATCH] Fix output of linearRegCostFunction --- ex5/ex5.py | 2 +- ex5/linearRegCostFunction.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ex5/ex5.py b/ex5/ex5.py index 23318ab..afcde38 100644 --- a/ex5/ex5.py +++ b/ex5/ex5.py @@ -61,7 +61,7 @@ # regression. theta = np.array([1, 1]) -J = linearRegCostFunction(np.column_stack((np.ones(m), X)), y, theta, Lambda=1)[0] +J, _ = linearRegCostFunction(np.column_stack((np.ones(m), X)), y, theta, Lambda=1) print('Cost at theta = [1 1]: %f \n(this value should be about 303.993192)\n' % J) diff --git a/ex5/linearRegCostFunction.py b/ex5/linearRegCostFunction.py index d87ebc7..02730a7 100644 --- a/ex5/linearRegCostFunction.py +++ b/ex5/linearRegCostFunction.py @@ -8,6 +8,8 @@ def linearRegCostFunction(X, y, theta, Lambda): """ # Initialize some useful values m = y.size # number of training examples + J = 0.0 + grad = 0.0 # ====================== YOUR CODE HERE =================================== # Instructions: Compute the cost and gradient of regularized linear