# Exercise 3 - conv\_forward error problem

**URL:** <https://community.deeplearning.ai/t/exercise-3-conv-forward-error-problem/26103>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [August 9, 2021, 5:07am UTC](https://community.deeplearning.ai/t/exercise-3-conv-forward-error-problem/26103 "2021-08-09T05:07:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven123](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@steven123](https://community.deeplearning.ai/u/steven123)\
**Post date:** [August 9, 2021, 5:07am UTC](https://community.deeplearning.ai/t/exercise-3-conv-forward-error-problem/26103/1 "2021-08-09T05:07:29Z")

</div>

I am stuck in this homework. I get this error:

* * *

ValueError 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)  
97 weights = W[:, :, :, c]  
98 biases = b[:,:,:, c]  
—\> 99 Z[i, h, w, c] = conv\_single\_step(a\_slice\_prev, weights, biases)  
100  
101

in conv\_single\_step(a\_slice\_prev, W, b)  
23 # Z = None  
24 # YOUR CODE STARTS HERE  
—\> 25 s = a\_slice\_prev \* W  
26 # Sum over all entries of the volume s.  
27 Z = np.sum(s) + np.float(b)

## ValueError: operands could not be broadcast together with shapes (2,3,9,4) (3,3,4)

This is my code, can somebody help me?

```auto
def conv_forward(A_prev, W, b, hparameters):
    
    # YOUR CODE STARTS HERE
{mentor edit: code removed - not allowed by the Honor Code
    # YOUR CODE ENDS HERE
    
    # Save information in "cache" for the backprop
    cache = (A_prev, W, b, hparameters)
    
    return Z, cache

```

---

<div class="post-metadata">

**Author:** ![jonaslalin](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jonaslalin/32/63_2.png) [@jonaslalin](https://community.deeplearning.ai/u/jonaslalin)\
**Post date:** [August 9, 2021, 6:36am UTC](https://community.deeplearning.ai/t/exercise-3-conv-forward-error-problem/26103/2 "2021-08-09T06:36:27Z")

</div>

Hello @steven123,

First of all, I have moved your post to the right place: #deep-learning-specialization:dls-course-4.

You have made a mistake when extracting

```python
a_slice_prev = A_prev_pad[vert_start:vert_end, horiz_start:horiz_end,:]

```

What is the difference between `A_prev_pad` and `a_prev_pad` and which one should you use in this case?
