WEEK 1- Exercise 2 - conv_single_step- Prog Asssignment - Issue with results

Hello Team,

wrf to title of the topic, implementation of this method is pretty straight forward,
In step >>

  1. Compute Element-wise product between a_slice_prev and W, here am using np.multiply to get the result.
  2. Sum over all entries of the volume, here am using np.sum
  3. Add bias

also am making sure that dtype is np.float64, by explicitly setting it in above steps.

Now upon comparing the results,

  • my implementation manages to pass 2 tests but fails 1.
  • in spite of explicitly setting the dtype = np.float64, am getting Error: Datatype mismatch at output.

Please help me understand, what am I missing here. What is the expected result here?

PFA error/output log

The first theory is that there is something wrong with the type of your Z value. So the first question is, “what type is it?” Then the next question is “how did it get that way?” :nerd_face:

I added the following print statement in a cell after the test cell (you can’t modify the test cell):

print(f"type(Z) = {type(Z)}")

And here’s what I get from that:

type(Z) = <class 'numpy.float64'>

What do you see when you do that?

One other thing to add here: there is an assertion in the test cell after the call to conv_single_step_test that makes it look like either np.float64 or np.float32 are ok for the type of Z. But that is not true: the test function requires it to be of type np.float64.

1 Like

Fixed it… Was returning as <numpy.ndarray> had to do np.float64(<var_name>) to get the expected datatype… Thanks