C4 W4 Convolutional Model, Step by Step. def conv_forward

Hello dear all. I think I have a silly coding problem, but for the live of me I cannot get it to work since yesterday. I am working on the following snippet:

Convolutional Neuron Networks / Week 1 / Convolutional Model, Step by Step.

I am stuck at the last step " [3.3 - Convolutional Neural Networks - Forward Pass]"

This is more a Python / Numpy thing, it seems: The following line is crashing when unpacking an array, giving me the following crash report:

ValueError                                Traceback (most recent call last)
<ipython-input-14-182241fd5e53> in <module>
      6                "stride": 2}
----> 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])

<ipython-input-13-badd9e29e296> in conv_forward(A_prev, W, b, hparameters)
     22     print(A_prev.shape)
---> 23     m, n_H_prev, n_W_prev, n_C_prev = A_prev
     25     # Retrieve dimensions from W's shape (≈1 line)

ValueError: not enough values to unpack (expected 4, got 2)

It is saying that it cannot unpack the values because there are too few.

However, when I print the shape of the incoming parameter, the shape shows all the 4 values, not just 2:

(2, 5, 7, 4)

Any pointers, would be greatly appreciated.

Thank you

You are spot on already. You should unpack the shape of A_prev, not A_prev itself :slight_smile:

1 Like

Oh man, thank you @jonaslalin , a really silly error which was fixed in about 2 seconds. Of course, now I see it.

Glad you replied! :sunglasses:

1 Like