# Course 1, Week 2, Exercise 5

Hey there
I found already some other topics about this Exercise, but none seems to fit my problem: In my opinion i have implemented the right functions. But i do get error messages that the results do not match. Could you please point me out, what i oversee? (I post this as well because i have read there were some issues with the test)

AssertionError Traceback (most recent call last)
in
14 print ("cost = " + str(cost))
15
β> 16 propagate_test(propagate)

~/work/release/W2A2/public_tests.py in propagate_test(target)
43 assert np.allclose(cost, expected_cost), f"Wrong values for cost. {cost} != {expected_cost}"

AssertionError: Wrong values for grads[βdwβ]. [[-0.00942637]
[ 0.22120096]
[-0.89922014]] != [[-0.03909333]
[ 0.12501464]
[-0.99960809]]

Many thanks in advance for any help!

Best Michael

It was a problem with the calculation of the activation matrix. I never checked this one before and just found out, that i had some issue there. Maybe this helps others as wellβ¦

I experienced a similar issue as @Michael_Lappert but the error I received was βWrong values for costβ function. I have tried computing the loss using different ways over the past couple of days now but unfortunately, I still keep getting this same error. Please can any one help

Hello Rizama,

Are you sure that you are applying the correct formula into the equations?

``````Forward Propagation:

You get X
You compute  π΄=π(π€ππ+π)=(π(1),π(2),...,π(πβ1),π(π))
You calculate the cost function:  π½=β1πβππ=1(π¦(π)log(π(π))+(1βπ¦(π))log(1βπ(π)))
Here are the two formulas you will be using:

βπ½βπ€=1ππ(π΄βπ)π(7)
βπ½βπ=1πβπ=1π(π(π)βπ¦(π))(8)
``````
1 Like

Yes, that was the issue. The cost function formula was correct just that I transposed the wrong matrices. I already fixed it. Thanks for the assistance

Good to know that Rizama!

Keep learning!

Hi there @Rashmi could you assist Iβm getting an error
C1 W2 Logistic Regression Excercise 4
AssertionError Traceback (most recent call last)
in
2 w, b = initialize_with_zeros(dim)
3
----> 4 assert type(b) == float
5 print ("w = " + str(w))
6 print ("b = " + str(b))

AssertionError:

If this is your first encounter with the βassertβ statement in python, it is checking for a condition that is supposed to evaluate to `True` (boolean) and it fails or βthrowsβ if it is not true. So what is the condition that is failing in your case? It is shown by the statement:

So your b value is supposed to be a python float, but it isnβt. So how did that happen? You probably assigned b with the value 0, but that is an integer value in python. Note that 0 and 0. are not the same thing in python. That decimal point makes the value a floating point number.