I got the following result after running the code and don’t know what does the sentence “Error: Wrong output for variable in position 0.” mean. Could you please help me? Thank you!
Z’s mean =
xxx
Z[0,2,1] =
xxx
cache_conv[0][1][2][3] =
xxx
Error: Wrong output for variable in position 0.
2 Tests passed
1 Tests failed
Looks like the value of Z for you is incorrect. Can you check if you’ve used the correct a_slice_prev and weights and biases, when you loop over the channels?
Thanks for the hint! I checked the code: a_slice_prev was calculated from a_prev_pad together with vert_start, vert_end…
Since we are in the loop n_C, it was [start: end, start:end, :]. Is it correct?
The weights and bias should be the same.
I couldn’t find my mistake in the code.
Okay that also feels like that’s correct. I am out of ideas what it could be then now, can you please post your code for the function? As soon as you’re able to figure out the issue, you should delete it.
Thank you for providing the code. You should check if you’ve taken the slice window (vertical and horizontal start and end) correctly with respect to the strides, that should solve your issue.
I changed the code to consider strike in for loop h and loop w in range (n_H/W, stride). c in range n_C should be looped w/o stride. But there is still mistakes in the code which I can’t find.
I got the follow message:
Error: Wrong output for variable in position 0.
2 Tests passed
1 Tests failed
~/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.
You should not need to change anything for the ranges in n_H and n_W because you calculated those a few lines earlier to keep stride in your mind. But know that the window moves stride times to the right or towards bottom for every step.
So if you started with horiz_start = 0, horiz_end = 2 let’s say for when you’re looping through n_W, and the stride is 4, the next horiz_start should be 4 and horiz_end should be 6.
You should review this lecture item to help with this. Good luck fixing the issue!
thank you very much for your quick reply. I thought firstly about using stride in calaculating horiz_start/end. But the first value should be start with 0. If I use stride as step in the loop, then it covers the start value zero.
for h in range(n_H, stride): v_start = h, h is from 0 to n_H-1 with step “stride”. first loop h= 0, second loop will be h=0+stride…This should be the same as you described above. Is it correct?
By the way: if stride = 4 as your example above and f = 2, why should the horiz_end = 8 and not 6?
Oh yeah, nice catch! I did not notice that I accidentally did that. Yes it would be 6 rather than 8. I’m sorry about that.
The provided formulas for n_H and n_W already keep the stride into account, so if you’re planning to use the range the way you are it’d be more of range(0, n_H*stride, stride) (you’ll have to specify the 0 as start because otherwise range defaults its arguments to (start, stop)). This should suffice for you.
But don’t you think there might just be an easier way to do it while calculating both vert_start, vert_end and horiz_start, horiz_end while keeping the range simply n_H/n_W?