Week2 Logistic_Regression_with_a_Neural_Network_mindset

I have an issue for Neural Network with deep learning course at week2 Logistic_Regression_with_a_Neural_Network_mindset assesment.
the issue is related with the assertions.
in the propagate function that assert the
assert type(grads[“db”]) == np.float64

however grads[“db”] type is ndarray in the real.
could you give me advice about this

Hello @erdogan_pacaci,

db should be a np.float64 instead of an array. Note that since b is a scalar ( we have assigned b = 1.5 a few lines above your assert line), db should also be a scalar ( we use b := b - \alpha \frac{\partial{J}}{\partial{b}}, right?)

Now, we have this formula:


which means that if we have m samples, we are going to have m differences (a^{(i)} - y ^{(i)}), but we need to sum all the differences up to one scalar number (of course we need also to divide it by m). If you have a nd.array, I would be wondering whether you have done the summation or not, have you?


PS: I will move your thread back to the category for Deep Learning Specialization Course 1. Please post your question to the DLS categories for DLS related questions :slight_smile:

Hello @rmwkwok
Thank you for fast replied.
I agree with you db is float.
However assertion check the grads[“db”] therefore issue is occured.
{code removed by mentor as we can’t share assignment code here}

I have added code for this:

But what did you assign to grads['db']?

{code removed by mentor as we can’t share assignment code here}

do you know what the second last line do? It creates a dictionary with two keys and their values. So, you assigned db to grads['db']

I suggest you to check for the type of db as well and see if it is a float. I think you are getting close to the source of the problem!

ok… thank you for your interest

{code removed by mentor}

now it is fixed .Thank you again