Convolution_model_Step_by_Step_v1 - Exercise 3 - conv_forward

I can’t find what error I’ve made. I have attached the notebook.

I get the following error message:
Z’s mean =

  • 0.5329033220060434*
    Z[0,2,1] =
  • [-0.05723279 0.03991888 -6.24285862 0.53960581 -5.04059676 6.96991358*
  • 3.69509379 -0.20955895]*
    cache_conv[0][1][2][3] =
  • [-1.1191154 1.9560789 -0.3264995 -1.34267579]*
    (2, 13, 15, 8)
    Error: Wrong output for variable in position 0.
  • 2 Tests passed*
  • 1 Tests failed*
    ---------------------------------------------------------------------------
    AssertionError Traceback (most recent call last)
    in
  • 11 print("cache_conv[0][1][2][3] =\n", cache_conv[0][1][2][3])*
    
  • 12 *
    

—> 13 conv_forward_test(conv_forward)

~/work/release/W1A1/public_tests.py in conv_forward_test(target)

  • 118 ]*
  • 119 *
    → 120 multiple_test(test_cases, target)
  • 121 *
  • 122 *

~/work/release/W1A1/test_utils.py in multiple_test(test_cases, target)

  • 151 print(‘\033[91m’, len(test_cases) - success, " Tests failed")*
  • 152 raise AssertionError(*
    → 153 “Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

AssertionError: Not all tests were passed for conv_forward. Check your equations and avoid using global variables inside the function.

{moderator edit - solution code removed}

Hi Tomerlshshalom,

Note the hint before the definitions of n_H and n_W in conv_forward. What is your code missing?

Also, do not forget to include the stride in your convolution!

Good luck!

1 Like

!!! I got a exactly the same value with you! I am pretty sure that there is nothing wrong in my code!

Sorry! I know why my codes are incorrect. It’s something wrong with h and w. We should step ‘stride’ steps at a time, right? I hope that will be help you.

Yes, that’s right: including the stride is crucial. But the other important thing to realize is that the stride applies in the input space, not the output space. The loops are over the output space and they must touch each element of the output space. The skipping caused by the stride happens on the input side.

1 Like

Thanks for reminding that crucial point!