# Course 4, Week 1 - conv_forward

Hi @jonaslalin !!

I am having a similar problem to the one you recently helped another user with here:

## In particular, here is my output log:

a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 3, 4)
weights dim (3, 3, 4)
a slice prev dim (3, 1, 4)
weights dim (3, 3, 4)

IndexError Traceback (most recent call last)
in
6 “stride”: 2}
7
----> 8 Z, cache_conv = conv_forward(A_prev, W, b, hparameters)
9 print(“Z’s mean =\n”, np.mean(Z))
10 print(“Z[0,2,1] =\n”, Z[0, 2, 1])

in conv_forward(A_prev, W, b, hparameters)
64 print(‘weights dim’, weights.shape)
65 biases = b[:,:, :, c]
—> 66 Z[i, h, w, c] = conv_single_step(a_slice_prev, weights, biases)
67 # YOUR CODE STARTS HERE
68

IndexError: index 4 is out of bounds for axis 2 with size 4

I’ve gone through a lot of posts on here, and can’t seem to understand why the last output of my a_prev dimension is (3,1,4) instead of (3,3,4). I really appreciate your time in helping with this.

Thanks,
hmd

EDIT: SOLVED BY @jonaslalin via private message

"Hello,

You need to loop over the output, not the input. Check your loops and see where that takes you."

1 Like

Thanks for adding a post with the solution:)

You need to loop over the output, not the input.

Good luck with other exercises!

2 Likes