Issue while calculating conv_single_step

Not sure what I’m doing wrong while calulating Z[i, h, w, c] while creating the conv_forward function

Hello Nicovlca,

Can you please guide me to which Course, Week, Assignment you’re talking about so I can help you more with this question.

Regards,

LinkedIn

1 Like

Hi, I am having the same issue, while I am using the conv_single_step defined in the previous task, but that only calculates a number Z, while the output expected in this function is Z[i, h, w, c] which I don’t really understand.

We are talking about the Assignment Convolutional Model, Step by Step, from the Course Convolutional Neural Networks and the Week 1, Exercise 3 - conv_forward.

Thanks!

OK, I’ve solved the problem which says ‘too many indices for array’.

It came from how I had defined the output variable Z, since I had just initialize it with the shape (n_H, n_W) instead of (m,n_H, n_W,n_C).

Great!!

1 Like

Hello Aangulo,

It is great that you found out the solution by yourself, I would love to assist with anything else if needed.

Regards,

LinkedIn

Hi @AmmarMohanna ,
It’s the conv forward function problem in week 1.
I initialized Z correctly but still get this error. Since I’m not allowed to write my code here, don’t know how to show you my work…


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

in conv_forward(A_prev, W, b, hparameters)
53
54 # Use the corners to define the (3D) slice of a_prev_pad (See Hint above the cell). (≈1 line)
—> 55 a_slice_prev = a_prev_pad[i, vert_start:vert_end, horiz_start:horiz_end, :]
56
57 # 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