hi

I am getting ValueError when defining the lstm_forward(x, a0, parameters) function.

```
ValueError Traceback (most recent call last)
<ipython-input-12-5b9326f2c416> in <module>
14 parameters_tmp['by'] = np.random.randn(2, 1)
15
---> 16 a_tmp, y_tmp, c_tmp, caches_tmp = lstm_forward(x_tmp, a0_tmp, parameters_tmp)
17 print("a[4][3][6] = ", a_tmp[4][3][6])
18 print("a.shape = ", a_tmp.shape)
<ipython-input-11-3881f1378e9d> in lstm_forward(x, a0, parameters)
55 a[:,:,t] = a_next
56 # Save the value of the next cell state (≈1 line)
---> 57 c[:,:,t] = c_next
58 # Save the value of the prediction in y (≈1 line)
59 y[:,:,t] = yt
ValueError: could not broadcast input array from shape (5,10) into shape (2,10)
```

I have defined the shapes as:

```
n_x, m, T_x = x.shape
n_y, n_a = parameters['Wy'].shape
```

what could be wrong please?

Your logic for setting the dimensions for y and a looks correct, but the error is being thrown on c, right? So where is the shape of that determined? And what should it be? Why did *c_next* end up with a different shape than c? This is how debugging works: you start from the error and then work backwards.

In case the error message seems ambiguous, it is telling you that the LHS of that assignment has shape (2, 10) and the RHS has shape (5.10). So which is correct and which is wrong? Once you know that, it should be clear where to look for the issue.

There is actually a little bit of Python voodoo going on in that statement that could make debugging a little harder. The variable `c`

has 3 dimensions. The variable `c_next`

has only 2. So straight assignment would always be an issue. However, the Python slicing and broadcasting magik that is happening there means you are iteratively assigning the 2 dimensions of `c_next`

into the first two dimensions of `c`

using the index `t`

as the third dimension of `c`

each time. This is why the error message only mentions 2 dimensions for both LHS and RHS as @paulinpaloalto mentions above.

Note that it’s only the first dimension that seems incorrect. So look back to the first dimension of `c`

when it was created and initialized. If you print out or otherwise examine the relative values of `n_y`

and `n_a`

and compare to the error message, you should see what happened here. Let us know?