C1W3 Lab 4 Error w/ 2.6 Learning parameters using gradient descent

Hi team!

So as I am trying to complete the section 2.6 Learning parameters using gradient descent of the logistic regression lab, I encountered this error where according to the instruction there is nothing I need to implement:

compute_gradient() takes 4 positional arguments but 5 were given

I did arrive the same test results in Exercise #3

dj_db at test w and b: -0.5999999999991071
dj_dw at test w and b: [-44.831353617873795, -44.37384124953978]
All tests passed!


So at this point this positional arguments error is super confusing and I dont know what I am missing.

please kindly advise! Thank you

1 Like

Did you modify any of the code in the gradient_descent() function?

No and frankly I don’t think I knew how.

Thanks!

also how can I reset the lab for a fresh start? Thanks!

Try the FAQ:

Hey, I’m also facing the same issue at 2.6 Learning parameters using gradient descent. This is the error I’m getting ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
8
9 w,b, J_history,_ = gradient_descent(X_train ,y_train, initial_w, initial_b,
—> 10 compute_cost, compute_gradient, alpha, iterations, 0)

in gradient_descent(X, y, w_in, b_in, cost_function, gradient_function, alpha, num_iters, lambda_)
32
33 # Calculate the gradient and update the parameters
—> 34 dj_db, dj_dw = gradient_function(X, y, w_in, b_in, lambda_)
35
36 # Update Parameters using w, b, alpha and gradient

TypeError: compute_gradient() takes 4 positional arguments but 5 were given

And these are of codes we couldn’t edit as well.

And I passed most of the exercises in the assignment but when I submitted I got 0% and the feedback was Cell #17. Can’t compile the student’s code. Error: TypeError(‘compute_gradient() takes 4 positional arguments but 5 were given’)

@Leo_Y
@shambhavi_mishra
{reply edited}

1 Like

Tip: Do not edit the definition of the compute_gradient() function. It should have five arguments, like this:

1 Like

Hey, thanks alot for your help :slight_smile: