Hi, thanks for help! I am working on exercise 3, and face a problem when using vectorization instead of for loop.
parts of my code are:
vert_start = n_Hstride
horiz_start = n_Wstride
horiz_end = horiz_start+f
…
weights = W[:,:,:,c]
biases = b[:,:,:,c]
There is an error as shown below:
----> 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)
75 horiz_end = horiz_start+f
76 a_slice_prev = A_prev_pad[vert_start:vert_end,horiz_start:horiz_end,:]
—> 77 weights = W[:,:,:,c]
78 biases = b[:,:,:,c]
79 Z[i, h, w, c] = conv_single_step(a_slice_prev,weights,biases)
NameError: name ‘c’ is not defined
I tried to using n_C instead of c, but another error happens:
in conv_forward(A_prev, W, b, hparameters)
75 horiz_end = horiz_start+f
76 a_slice_prev = A_prev_pad[vert_start:vert_end,horiz_start:horiz_end,:]
—> 77 weights = W[:,:,:,n_C]
78 biases = b[:,:,:,n_C]
79 Z[i, h, w, c] = conv_single_step(a_slice_prev,weights,biases)
IndexError: index 8 is out of bounds for axis 3 with size 8
What shoud I do ? Can anyone help me ? Thanks again!