Week 1: Excersie 7 - lstm_cell_backed

Hi,

I am have been trying to figure out what exactly it is I am doing wrong with the calculations for da_prev and dxt.

I am able to get the correct outputs (values and shapes) for all of the test cases apart from for da_prev and dxt.

Output:

gradients["dxt"][1][2] = -2.5364353124224213
gradients["dxt"].shape = (5, 10)
gradients["da_prev"][2][3] = -0.676972989383245
gradients["da_prev"].shape = (5, 10)

I know the shape for da_prev is correct but I cannot figure out what I am doing wrong in the calculation. I am transposing and trying to account for the concatenation in the weights by doing:

ft[:n_a,:].T @ dft

As far as I understand the equations provided:

W_f^T d\gamma_f^{\langle t \rangle}
and Here, to account for concatenation, the weights for equations 19 are the first n_a, (i.e. W_f = W_f[:,:n_a] etc…)

I should be doing the correct thing? Am I missing something obvious here?

Any help would be appreciated. Thanks!

I may just be missing your point, but ft is not involved in the computation for da_prev. It is a sum of 4 terms, the first of which is similar to what you wrote but involving W_f not ft.

Of course there are a lot of details that you need to get exactly right in all of this. The first step is to compare carefully to the math formulas shown in the instructions.