Programming Assignment - Week 1 - Distribute Value

Hi, I am recieving this error contniously and I don’t understand what am I doing wrong.
I calculate the average using average = np.average(dz) and I have tried both, np.ones and np.full to generate a, but no success. Please help. Thank You

Well, I’ve solved it using average = dz / (n_H*n_W), but a mentor on another thread suggested np.average for this step. If np.average can work, can somebody explain how?

Hi,

It is given that dz -- input scalar, so, using np.average() or np.mean() won’t work here. Even if dz was a vector, they still won’t work. We need to divide it by n_H and n_W, as you did. Moreover, by default, np.full() produce integers, but we need floats, so, it won’t work. Lastly, np.ones() should work correctly here, if you specify the correct argument. Did you check the hint, given in a notebook? What error you are getting with np.ones()?

Best,
Saif.

I get this error using np.ones but I’ve solved it using np.full

According to the documentation, np.ones() only takes shape as an argument but it doesn’t take a fill_value argument like np.full()

You don’t need to fill any value in np.ones(). As the name implies, it produces an array of a given shape, with all values equal to one.

Best,
Saif.

Yes, but if I use np.ones(), I don’t pass the tests

So, what error you are getting with np.ones()? And what is the input argument to that?