In the backward pass equations 7-21 there are two equations: da_prev and dxt that appear to be the exact same equation… It also states that for da_prev the forget weight Wf uses na index for the first n_a… so it says wf[:,: na]
This doesn’t make much sense to me because I thought there would need to be a comma in there and maybe it was a typo. It mentioned something about too many indices so I took out a colon. by using Wf[:, na] it ended up moving forward in the program to the next error…
dxt. In this case it says to use na from first till the end. so i switched it to Wf[na, :] note again the instruction has a weird typo? Wf[:,na :] which seems to be a typo. Just by adding the comma however it again says too many indices. Taking out one of the colons results in the error:
IndexError Traceback (most recent call last)
in
19 da_next_tmp = np.random.randn(5,10)
20 dc_next_tmp = np.random.randn(5,10)
—> 21 gradients_tmp = lstm_cell_backward(da_next_tmp, dc_next_tmp, cache_tmp)
22 print(“gradients["dxt"][1][2] =”, gradients_tmp[“dxt”][1][2])
23 print(“gradients["dxt"].shape =”, gradients_tmp[“dxt”].shape)
in lstm_cell_backward(da_next, dc_next, cache)
59 da_prev = np.dot(parameters[‘Wf’][:,n_a].T, dft) + np.dot(parameters[‘Wi’][:,n_a].T, dit) + np.dot(parameters[‘Wc’][:,n_a].T, dcct) + np.dot(parameters[‘Wo’][:,n_a].T, dot)
60 dc_prev = dc_next * ft + ot * (1 - np.square(np.tanh(c_next))) * ft * da_next
—> 61 dxt = np.dot(parameters[‘Wf’][n_a,:].T, dft) + np.dot(parameters[‘Wi’][n_a,:].T, dit) + np.dot(parameters[‘Wc’][n_a,:].T, dcct) + np.dot(parameters[‘Wo’][n_a,:].T, dot)
62 ### END CODE HERE ###
63
IndexError: index 5 is out of bounds for axis 0 with size 5