Week 1 Assignment 1 new conv_forward

I am getting an error pointing to some issue with a_slice_prev, however I don’t see what I did wrong:

a_slice_prev = a_prev_pad[i, vert_start:vert_end, horiz_start:horiz_end, :]

This should already be the right dimension assuming I did all the start/end indices right. Can someone provide some direction?

in conv_forward(A_prev, W, b, hparameters)
89
90 # Use the corners to define the (3D) slice of a_prev_pad (See Hint above the cell). (≈1 line)
—> 91 a_slice_prev = a_prev_pad[i, vert_start:vert_end, horiz_start:horiz_end, :]
92
93 # Convolve the (3D) slice with the correct filter W and bias b, to get back one output neuron. (≈3 line)

IndexError: too many indices for array

The problem is you have already sliced on the samples dimension to get a_prev_pad, right? But you’re slicing it again on that dimension. But it’s already only a 3D array, right?

The error message is about as clear as you could hope for. Print the shape of a_prev_pad right before the line that throws. What do you get?

Ahh, that’s it!. Thanks Paul. I totally forgot a_prev_pad was already sliced and kept thinking I messed up the indices somehow.

Hmmmm. Error messages can sometimes be a bit hard to interpret, but this one seems pretty “on the nose” :nerd_face: