# DLS 4, Week 1, Exercise 3 (CNN - Forward Pass)

Hello,
I have a problem figuring out what I did wrong with Z

I keep getting this (was stuck on it for a while)
Z’s mean =
0.01656131976770792
Z[0,2,1] =
[0. 0. 0. 0. 0. 0. 0. 0.]
cache_conv[0][1][2][3] =
[-1.1191154 1.9560789 -0.3264995 -1.34267579]

Assertion Error: "Wrong Z mean. Expected: -0.5384027772160062 got: 0.0

There were issues similar to this, and I tried to implement some of the solutions suggested. Unfortunately, it didn’t solve my main issue.
Can somebody help? I would really appreciate it.

Hi @Mohammad_Almasri , thanks to the Discourse community and good to see you progressing through the course. For this particular exercise, I think it’s best to go back to the original structure of the Lab and stick to that. The initial part up to the for-loops looks okay, but you should use the for loops and range as presented in the exercise and not update them. The vert_start, horiz_start should be within all for-loops and should include the stride (not the stride within the range of the for loops). Actually this also makes the code much simpeler. Hope this helps you further (I cannot give the full solution of course), and keep us in the loop how it is going. Best Stephanus

Right! As Stephanus points out, you are not handling the stride correctly. Think about the meaning of the h and w values in the loop: you will eventually use them as index values into the output array, right? The way to think of the loops is that you are looping over the output space and you need to touch every point in the output space. But the stride determines where you are in the input space to compute the corresponding value in the output space.

1 Like

thanks for replying, stride was in fact, the exact problem. it was a bit tricky getting to the solution, but it finally worked out for me, thanks!

yeah, it makes sense actually, that’s why adding stride as a step in the for loop was wrong. after modifying a bit, I managed to solve the issue, thank you!

Very useful, thank you