I have been reading all the posts on solutions for this exercise. I also have been stuck for a day and feel I already implemented the stride correctly here, but my code is still not passing the test and crashing some steps forward due to a mismatch in the array’s dimension. Could you please help me with some paths I could take differently? Thanks!
What is the error message that you are seeing? It’s fine to show the full exception trace, even if that reveals a few lines of code.
Note that it looks like your handling of the stride is correct, but (as Tom says) that’s not all that you need to get right. E.g. perhaps the shape of A_prev_pad is not correct.
Sorry about posting the code above. I have experimented with all the assignments before the loop and I am still having a hard time. The exception trace is below and it seems that at a certain point a_prev_slice goes from 3,3,4 to 2,3,4 and I am not sure why.
in conv_single_step(a_slice_prev, W, b)
23 # Z = None
24 # YOUR CODE STARTS HERE
—> 25 s = a_slice_prev * W
26 Z = np.sum(s)
27 Z = Z + float(b)
ValueError: operands could not be broadcast together with shapes (2,3,4) (3,3,4)
Oh, sorry, I didn’t read your code carefully enough the first time: I was only looking at the stride logic. You handle that correctly, but when you “slice” a_prev_pad, you have the h and w dimensions reversed. The h should come first and h stands for “height” here, not horizontal, right? w is for width or horizontal and it comes after the vertical dimension.