C5_W1_A1_Exercise 2 - rnn_forward


I am getting an assertion error “wrong values in a” and I am trying to figure out my mistake.

What I have done so far:

  1. Initialize a, and y_pred with zeros of shape (na,m,Tx) for a, and (ny,m,Tx) for y_pred using numpy.zeros() function.

  2. Initialize a_next to function parameter a0

  3. Loop for each t in T_x range:

  • get xt by slicing function parameter x, thinking is get all the first dimension, get all the second dimension, get only the t, third dimension.
    -run rnn_cell_forward with xt, a0, and parameters as arguments
  • save the output a_next in the corresponding t of a.

And I leave it there for now as the assertion error is for a.

My rnn_cell_forward function passess all tests, double checked and also cant seem to find the mistake in there.

Thanks for the help :slight_smile:

1 Like


The second parameter passed to rnn_cell_forward() should be a_next, not a0. As a_next was initialised to a0, and updated in at each subsequent loop round.


thanks for the help, that was it