W2_A2_Ex-4_initialize_with_zeros

I saw previous answers to change dim = 2 to 2.0, but I’m unable to change it, why can’t I make any changes in that cell? also, why am I getting an assertion error in propagate function?

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:

AssertionError Traceback (most recent call last)
in
7 assert type(grads[“dw”]) == np.ndarray
8 assert grads[“dw”].shape == (2, 1)
----> 9 assert type(grads[“db”]) == np.float64
10
11

AssertionError:

Hello @SivaramaKrishnan! I hope you are doing well.

You don’t need to change the dim to 2.0. These cells are locked. You just need to write your code in cells starting with # GRADED FUNCTION and don’t need to write or change any other cells.

Regarding the error in propagate function, may be you are making mistakes. Make sure you are implementing all the codes correctly. Hint is given:

Let me know if you are facing errors to implement the code.

Best,
Saif.

1 Like

Hi @SivaramaKrishnan ,

The problem is in initialize_with_zeros(), where b is initialized. Here, b should be assigned with the datatype float, you can do it like this:
b = 0.0

1 Like

Thank you @saifkhanengr, i changed b = 0.0 as suggested by @Kic , but the propagate, still throws,

AssertionError Traceback (most recent call last)
in
7 assert type(grads[“dw”]) == np.ndarray
8 assert grads[“dw”].shape == (2, 1)
----> 9 assert type(grads[“db”]) == np.float64
10
11

AssertionError:

this is my code, is it correct ?

Hi @SivaramaKrishnan!

Your cost is incorrect. You missed the dot product between y & log(a) and (1-y) & log(1-a). See the below figure. First, you have to use sum; then inside that, you have to use dot; and then inside that, you have to use log function. Furthermore, you don’t need to use “*” , dot function will handle this.

Also, make sure that the indentations are correct. The code you provided has the wrong indentation for A.

Moreover, what lead you to use axis=1 in db?

Note: Kindly delete the code you shared as this is against the community Honor Code.

Best,
Saif.