Week 1 Assignment : Exercise 3 conv_forward

Hello,

I’m stuck on assigning the weights and biases. Could someone please help me out? I’m not too sure what I’m doing wrong. I would paste the error that I’m getting, but it contains my code. It’s pointing to ‘weights=~~’. My ‘a_slice_prev’ has 3 dimensions, my weights have 4 and my biases also have 4. All of their last dimensions are being iterated by ‘c,’ whose ranges is n_C.

Posting an error message that happens to include parts of your code is perfectly fine.

2 Likes

Sure, as Tom says, it’s ok to post an exception trace, even though it may reveal some source code. Debugging is hard enough even with some evidence to work with. :scream_cat:

One thing to check is the shapes of the objects in question. I added some print statements to my conv_forward logic. Here’s what I get for the test cell for conv_forward:

New dimensions = 3 by 4
Shape Z = (2, 3, 4, 8)
Shape A_prev_pad = (2, 7, 9, 4)
Z[0,0,0,0] = -2.651123629553914
Z[1,2,3,7] = 0.4427056509973153
Z's mean =
 0.5511276474566768
Z[0,2,1] =
 [-2.17796037  8.07171329 -0.5772704   3.36286738  4.48113645 -2.89198428
 10.99288867  3.03171932]
cache_conv[0][1][2][3] =
 [-1.1191154   1.9560789  -0.3264995  -1.34267579]
New dimensions = 9 by 11
Shape Z = (2, 9, 11, 8)
Shape A_prev_pad = (2, 11, 13, 4)
Z[0,0,0,0] = -1.2238796505752447
Z[1,8,10,7] = -0.47458986707940803
New dimensions = 2 by 3
Shape Z = (2, 2, 3, 8)
Shape A_prev_pad = (2, 5, 7, 4)
Z[0,0,0,0] = 3.14880664541713
Z[1,1,2,7] = 1.0956417259542868
New dimensions = 13 by 15
Shape Z = (2, 13, 15, 8)
Shape A_prev_pad = (2, 17, 19, 4)
Z[0,0,0,0] = -0.5096687406137471
Z[1,12,14,7] = -0.3247422640409677
(2, 13, 15, 8)
New dimensions = 3 by 4
Shape Z = (2, 3, 4, 8)
Shape A_prev_pad = (2, 7, 9, 4)
Z[0,0,0,0] = -2.651123629553914
Z[1,2,3,7] = 0.4427056509973153
New dimensions = 3 by 4
Shape Z = (2, 3, 4, 8)
Shape A_prev_pad = (2, 7, 9, 4)
Z[0,0,0,0] = -2.651123629553914
Z[1,2,3,7] = 0.4427056509973153
New dimensions = 3 by 4
Shape Z = (2, 3, 4, 8)
Shape A_prev_pad = (2, 7, 9, 4)
Z[0,0,0,0] = -2.651123629553914
Z[1,2,3,7] = 0.4427056509973153
 All tests passed.
1 Like

Hello, thank you! debugging with print statements helped me out.