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