conv_forward(A_prev, W, b, hparameters)
my shapes are correct until my w = 3 step?
i, h, w, c: 0 0 2 7
vert start/end: 1 4
horiz start/end: 5 8
W.shape, weights.shape: (3, 3, 4, 8) (3, 3, 4)
a_slice_prev.shape, weights.shape, biases.shape: (3, 3, 4) (3, 3, 4) (1, 1, 1)
i, h, w, c: 0 0 3 0
vert start/end: 1 4
horiz start/end: 7 10
W.shape, weights.shape: (3, 3, 4, 8) (3, 3, 4)
a_slice_prev.shape, weights.shape, biases.shape: (3, **2**, 4) (3, 3, 4) (1, 1, 1)
It looks like your striding logic must be incorrect. Have you seen this post?
One common error is to add the stride in the output space: the striding happens only in the input space. The loops are over the output space and must touch every element of that space.
Another common error is mixing up the vertical and horizontal dimensions. h stands for “height”, not “horizontal”.
1 Like
Thanks for the response. You have to morph the n_W, n_H indices to map onto the padded input shape, and taking out a pencil and paper and realizing that what I was looking for depends on the stride and f solved it.
1 Like
Glad to hear you found the solution. I’m guessing the answer probably was based on the formula that was given in the lectures and the assignment to compute the output size based on the input size, filter size, stride and padding:
n_{out} = \displaystyle \lfloor \frac {n_{in} + 2p - f}{s} \rfloor + 1
For anyone else who later finds this thread.
As a footnote, the symbols \lfloor and \rfloor that you see in the above formula are not just fancy parentheses: they are the mathematical function “floor”, which returns the greatest integer less than the contained value. When the stride is not 1, that fraction may not produce an integer, but the result needs to be an integer of course.
1 Like