Getting an Error — AssertionError: Wrong value for dj_db. Expected: 0.28936094 got: 0.2998402688874882

Checked Indentation and hints but still persists

This kind of error has not got to do with identation but with the formula you compute that gradient.

I would check that If I were you.

Yes, I computed with no error and even I got the values also as

dj_db at initial w and b (zeros):-0.1
dj_dw at initial w and b (zeros):[-12.00921658929115, -11.262842205513591]

But while compiling the below code I’m getting the error

Can anyone check and help me exactly where is my fault?

The most common errors in this assignment are:

  • using incorrect indentation.
  • including the “divide by m” portion within a for-loop.
  • and there are all manner of ills possible if you’re using two for-loops, one over the features nested within a for-loop over the examples.
1 Like

Thanks, TMosh
I checked each and every indentation even For -loop but it seems to be correct , but don’t know why I’m getting this error

Can I share my Notebook, so that you can replicate the issue at your end?

(edited my reply to myself).

Done, Please check :blush:

It was due to incorrect indentation.Thanks got it.

hello Deb,

I have same error. Can you tell me where should I look for this indentation error? is it at dj_db_i code??

I am facing following error:
NameError Traceback (most recent call last)
1 # Compute and display gradient with w and b initialized to zeros
----> 2 initial_w = np.zeros(n)
3 initial_b = 0.
5 dj_db, dj_dw = compute_gradient(X_train, y_train, initial_w, initial_b)

NameError: name ‘n’ is not defined

however n is already defined in the main code as :
m, n = X_train.shape
can i have some guidance

Please run all the above cells.

I did but it still not working

Please do Kernel → Restart and Clear output and run all the cells again

Thank you it worked. But now there is one more problem. my expected cost value is coming as 0.22 and it does not changed from very first iteration till last where as actual answer should be 0.30

Please create a new post and share your full error.