# [week 1] conv_forward error

Hi everyone,

I am very stuck with exercise 3

I get this Error : Wrong output for variable in position 0.

I’ll try to describe my code without violating the coursera honor code:

Retreive (m, n_H_prev, n_W_prev, n_C_prev) from A_prev shape
Retreive (f, f, n_C_prev, n_C) from W shape
Retreive stride and padding from hparameters python dictionnary
Calculate n_H and n_W using the formula and the int() function as floor before adding the one
Initialize Z with dimensions (m ,n_H, n_W, n_C)

Loops:

{mentor edit: detailed description of code removed. The Honor Code does not allow posting your code. If your description is so detailed as to recreate your code, it’s the same as posting the code itself}

This is the complete output:

## Z’s mean = 0.4635416666666667 Z[0,2,1] = [-2 8 0 3 4 -2 10 3] 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.

I have found the problem. I have focused on the loops and the slides, but the problem wasn’t there.

I will describe the debug proccess I have followed just in case it can be helpful to someone.

• I have openened the public_tests.py file in order to locate the input test
• I have openen the outputs.py file in order to locate the expected test.
• I have recreated the test in a small function and compare the results:
``````def custom_test():
np.random.seed(1)
A_prev = np.random.randn(2, 5, 7, 4)
W = np.random.randn(3, 3, 4, 8)
b = np.random.randn(1, 1, 1, 8)
Z, cache = conv_forward(A_prev, W, b, hparameters)
print (Z)
print (conv_forward_output0)
``````
• I have noted that the output Z seems to be similar to conv_forward_output0, but with all the values rounded.
• Also I have printed the result of the function conv_single_step() and it was a float.
• So the only place where the values could be rounded was the line with the asigment to the Z matriz cell. Z[i, h, w, c]= conv_single_step(a_slice_prev, weights, biases)
• I reviewed the Z initialization Z = {code removed} and I have changed it to Z = {code removed} and then I pass the test.

So the problem was the initialization of Z with int 0 values, instead of 0 float values.

Hope this all helps someone else.