In week 1 assignment Building_a_Recurrent_Neural_Network_Step_by_Step. I got this error.

1 Like

**Error:**

The error indicates that the shapes of variables do not match in the following lines:

`a[:,:,t] = a_next`

`y_pred[:,:,t] = yt_pred`

**What to do?**

Ensure that `a`

, `y_pred`

, `a_next`

, and `yt_pred`

are initialized with the correct shapes. Also, make sure that `a_next`

and `yt_pred`

returned by `rnn_cell_forward`

have the expected shapes.

Hope this helps!

2 Likes

in my opinion, if you understand how broadcasting works, you will be able to solve this issue.

Here is a quick reference-> Broadcasting — NumPy v2.0 Manual

1 Like

If you look at the test case there, you see that n_x = 3 and n_a = 5, so this is some kind of a dimension mismatch problem. E.g. that you are using some version of a where you should be using x or vice versa.