Course4, Week1, Ex. 3 Conv Forward

Hi, I am wondering how I may get around this error. I noticed that the start and end arrays have type float. I tried to use astype(int) and restart kernel, however it didn’t fix this error. Could someone please help?


TypeError 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)
55
56 # Use the corners to define the (3D) slice of a_prev_pad (See Hint above the cell). (≈1 line)
—> 57 a_slice_prev = a_prev_pad[vert_start:vert_end,horiz_start:horiz_end,:]
58
59 # Convolve the (3D) slice with the correct filter W and bias b, to get back one output neuron. (≈3 line)

TypeError: only integer scalar arrays can be converted to a scalar index

I guess your vert_start, vert_end, horiz_start, horiz_end are not correct. Please check this link.

1 Like