DLS Course 4 Week 1 Assignment 1 Wx 3

Hi Everyone I’m getting a weird err
my a_slice_prev.shape changes on the final iteration of c

(2, 7, 9, 4)
(7, 9, 4)
(3, 3, 4)
(2, 7, 9, 4)
(7, 9, 4)
(3, 3, 4)
(2, 7, 9, 4)
(7, 9, 4)
(3, 2, 4)

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

in conv_forward(A_prev, W, b, hparameters)
92 print(a_prev_pad.shape)
93 print(a_slice_prev.shape)
—> 94 Z[i, h, w, c] = conv_single_step(a_slice_prev, weights, biases)
95
96 # YOUR CODE ENDS HERE

in conv_single_step(a_slice_prev, W, b)
23 # Z = None
24 # YOUR CODE STARTS HERE
—> 25 s = np.multiply(a_slice_prev, W)
26 Z = np.sum(s)
27 Z = Z + float(b)

ValueError: operands could not be broadcast together with shapes (3,2,4) (3,3,4)

Most likely there is an error in your conv_forward() function, in one of these areas:

  • incorrect slicing of A_prev_pad
  • incorrect vertical or horizontal index values, regarding use of “stride”.
  • incorrect slicing of a_prev_pad, the weights, or the biases.

Thank you very much Tom
It was the stride value