W1 Assignment 1 Exercise 4: Wrong shape for caches

Hi, I am doing Assignment 1 for Week 1 of Sequence models(C5).

In Exercise 4, I keep getting error of:

AssertionError: Wrong shape for caches. 10 != 16

I don’t know what I did wrong. Can someone help me with this issue?

If you look at the core logic in that function, the caches variable will get an entry for every iteration of the “for” loop there. And the range on that loop is T_x. So it looks like you must be initializing that value incorrectly. There are several test cases in that test cell and I added a bunch of print statements to my code. Here’s what I see:

T_x 7
c.shape (5, 10, 7)
y.shape (2, 10, 7)
len(caches) 2
len(caches[0]) 7
a[4][3][6] =  0.17211776753291672
a.shape =  (5, 10, 7)
y[1][4][3] = 0.9508734618501101
y.shape =  (2, 10, 7)
caches[1][1][1] =
 [ 0.82797464  0.23009474  0.76201118 -0.22232814 -0.20075807  0.18656139
  0.41005165]
c[1][2][1] -0.8555449167181981
len(caches) =  2
T_x 16
c.shape (3, 13, 16)
y.shape (2, 13, 16)
len(caches) 2
len(caches[0]) 16
All tests passed

So my guess is that for some reason you are getting T_x as 10 in that last test case. So how could that happen? Try printing your T_x values and see what you are getting.