Course 5, Week 1, Assignment 1: "rnn_forward"

There is something wrong in the for loop in rnn_forward.
I get an error “wrong values for a”.
Can you please help?

loop over all time-steps

for t in range(T_x):
    # Update next hidden state, compute the prediction, get the cache (≈1 line)
    # code removed

Please do not post your code in this community. This is not recommended.

Think about the first iteration, i.e, t=0. What a[:,:,t-1] will be ? (Python starts from 0.)
If you look at some initial value settings before entering this loop, you will find which variable should be used for this iteration. Please revisit this portion, a[:,:,t-1].
Hope this helps.

2 Likes

I used a_next and it solved the issue. Thanks for the help.