DLS 5 Week 1: Exercise 7 - lstm_cell_backward: output is not an expected one

After I completed my function , the result was not the expected.

My output:

gradients[“dxt”][1][2] = 2.12579913944835
gradients[“dxt”].shape = (3, 10)
gradients[“da_prev”][2][3] = -0.20552946045398332
gradients[“da_prev”].shape = (5, 10)
gradients[“dc_prev”][2][3] = 0.7975220387970015
gradients[“dc_prev”].shape = (5, 10)
gradients[“dWf”][3][1] = -0.2640682847873236
gradients[“dWf”].shape = (5, 8)
gradients[“dWi”][1][2] = 1.5829585105119015
gradients[“dWi”].shape = (5, 8)
gradients[“dWc”][3][1] = -1.5415530038483163
gradients[“dWc”].shape = (5, 8)
gradients[“dWo”][1][2] = 0.3313115952892109
gradients[“dWo”].shape = (5, 8)
gradients[“dbf”][4] = [-0.77359774]
gradients[“dbf”].shape = (5, 1)
gradients[“dbi”][4] = [-0.32039169]
gradients[“dbi”].shape = (5, 1)
gradients[“dbc”][4] = [0.23712318]
gradients[“dbc”].shape = (5, 1)
gradients[“dbo”][4] = [0.13893342]
gradients[“dbo”].shape = (5, 1)

Expected output:

gradients[“dxt”][1][2] = 3.23055911511
gradients[“dxt”].shape = (3, 10)
gradients[“da_prev”][2][3] = -0.0639621419711
gradients[“da_prev”].shape = (5, 10)
gradients[“dc_prev”][2][3] = 0.797522038797
gradients[“dc_prev”].shape = (5, 10)
gradients[“dWf”][3][1] = -0.147954838164
gradients[“dWf”].shape = (5, 8)
gradients[“dWi”][1][2] = 1.05749805523
gradients[“dWi”].shape = (5, 8)
gradients[“dWc”][3][1] = 2.30456216369
gradients[“dWc”].shape = (5, 8)
gradients[“dWo”][1][2] = 0.331311595289
gradients[“dWo”].shape = (5, 8)
gradients[“dbf”][4] = [ 0.18864637]
gradients[“dbf”].shape = (5, 1)
gradients[“dbi”][4] = [-0.40142491]
gradients[“dbi”].shape = (5, 1)
gradients[“dbc”][4] = [ 0.25587763]
gradients[“dbc”].shape = (5, 1)
gradients[“dbo”][4] = [ 0.13893342]
gradients[“dbo”].shape = (5, 1)

Your equations for dbf, dbi, and dbc are wrong. Will definitely need to fix those. I had a similar issue and once those were corrected, everything else worked.

image

I went through a similar issue. To me, the problem was that I missed opening the first parenthesis for dcct, dit and dft. Then, I didn’t close the other parenthesis after the tanh operations.

This led to no compilation errors, but wrong results.

Hope this helps.