My code seems correct to me but I am getting an error that says my shapes are incorrect , since this is an optional part I think I am allowed to paste the code so here it is below.
{moderator edit - solution code removed}
My code seems correct to me but I am getting an error that says my shapes are incorrect , since this is an optional part I think I am allowed to paste the code so here it is below.
{moderator edit - solution code removed}
here is the error
ValueError Traceback (most recent call last)
in
11 a_tmp, y_tmp, caches_tmp = rnn_forward(x_tmp, a0_tmp, parameters_tmp)
12 da_tmp = np.random.randn(5, 10, 4)
—> 13 gradients_tmp = rnn_backward(da_tmp, caches_tmp)
14
15 print(“gradients["dx"][1][2] =”, gradients_tmp[“dx”][1][2])
in rnn_backward(da, caches)
45 dx[:, :, t] = dxt
46 dWax += dWaxt
—> 47 dWaa += dWaat
48 dba += dbat
49
ValueError: operands could not be broadcast together with shapes (5,5) (5,3) (5,5)
Print the shapes of dWaa
and dWaat
to see which is wrong. And where do those come from? They are return values from rnn_cell_backward
, right? Did that code pass the tests? But a correct function can still return bad values if you pass it bad values. The GIGO principle applies here as well as in “real life”.
I think the mistake is that you are passing the wrong arguments to rnn_cell_backward
when you call it in the loop. Please take a more careful look at the instructions and consider the intent there in terms of timesteps.
Hi paul, thank you for the quick response, the issue ended up being a small typo in rnn_cell_backward!
Interesting. It’s great news that you found the solution, but there was also a definite problem in the arguments you were passing to rnn_cell_backward
.
i figured out that part as well!