Problems about function rnn_backward() and lstm_backward().
I passed the test of rnn_cell_backward() and lstm_cell_backward().
And my shapes of results of rnn_backward() and lstm_backward() are correct. But the values seem to be wrong. Below are my codes, I do not know where is the problem, please help me.
The problem is in the first function you did not initialized with zeros and the proper shape the gradient da_prev. In the second function you have an extra line in order to initialize the gradient da_prevt specifically da_prevt = da[:, :, -1]. Please initialize this gradient the same way you initialized the others using the correct shape.
As I hinted before da_prevt should be initialized with an np.array of zeros and the appropriate shape and nothing more. The rest of the code (not including the initialization of that gradient) seems OK.
I had a similar issue with rnn_backward function and my code was very similar to what NocturneJay posted. Eventually I made it work and got the expected output but just setting da_prevt to an array of zeros was not sufficient. Only changing this one line means that we pass the array of zeros as the first argument of rnn_cell_backward, and I guess this is not what we want because we should use da. I also modified the line 'gradients = rnn_cell_backward(…, …) after examining Figure 7 in the notebook.
That is correct you need to include as an argument da in the function rnn_cell_backward or in the function lstm_cell_backward. I though it could be inferred as da is an argument of the function rnn_backward or the function lstm_backward. I hope this reaffirm your comment.
@raha you ever get this fixed? If you create a new question and add your lstm code I’ll give it a look. Just worked through the back-prop questions so might be able to help.