Course 4 Week 1 Assignment 1 (50/100)

I have added stride into calculation for loop n_W and n_H( 0, n_H, stride) with step as stride.
v_start = h and v_end = h + f ( also same for width)

Not sure how to debug this, as all the test cases pass. Some hidden test case does not pass.
Any other suggestions to debug this?


1 Like

That is not the correct way to implement the stride. It works as long as stride = 1, but fails for stride = 2. Unfortunately the test cases are broken and don’t really “throw” when this happens. You should see that the outputs of the stride = 2 test case for pool_forward are wrong: they all need to agree, not just the first row.

The way to think about this is that the stride happens in the input space, not the output space. The loops here are over the output space and you must touch every point in the output space and not skip any. Then you use the stride to calculate where that given output value comes from in the input space. Your implementation will be skipping points in the output space, right?

When stride = 2, your code causes the loop to skip over half of the values in the ranges of n_W and n_H.

I was able to resolve the issue. Thanks for your inputs.