# W4 A1 | Exercise-5 | L_model_forward - Shape error

I have a strange problem that I spend a lot of time on, to solve. But I could not solve it!!!
Can any one help me?
My answer is true as it is seen in the photo!

Hey @Sina_Kian,
Since you have posted your query in the General Discussions, itâ€™s hard to figure out as to which assignment, which week, which course and which specialization you are referring to. Can you please let us know these, so that we are able to help you out?

Cheers,
Elemento

I think this is an assignment W4A1 in Course 1.

Looks like â€ś`AL`â€ť is OK, but â€ś`caches`â€ť is not. Please look at the hint in this assignment, and check your implementation.

• Donâ€™t forget to keep track of the caches in the â€ścachesâ€ť list. To add a new value `c` to a `list`, you can use `list.append(c)`.
1 Like

Yes, this sounds like DLS C1 W4 A1. I used the little â€śedit pencilâ€ť on the title to move it to the correct category.

1 Like

I used â€śappendâ€ť to add item in the list. It is very strange.

After a unit test, a test program gets `t_AL` and` t_caches`.
So, analyzing â€ś`t_caches`â€ť can be the way to identify where is the bug.

Here is the way to analyze.

``````print(type(t_caches))             # "caches" is a list
print(len(t_caches))              #   of 3 elements = "cache" from 3 layers
print(type(t_caches[0]))          # each element in "caches" is "tuple" of
print(len(t_caches[0]))           #   (linear_cache, activation_cache),i.e, length=2
print(type(t_caches[0][0]))       # "linear_cache" is a tuple
print(len(t_caches[0][0]))        #   with 3 elements
print(type(t_caches[0][0][0]))    # The first element in "linear_cache" is an array
print(t_caches[0][0][0].shape)    #   Its shape is (5,4) = A

<class 'list'>
3
<class 'tuple'>
2
<class 'tuple'>
3
<class 'numpy.ndarray'>
(5, 4)
``````

If appending â€ścacheâ€ť into â€ścachesâ€ť is not done correctly in â€ś`L_mode_forward()`â€ť, then, first two may have different values.
3rd and 4th are â€ścacheâ€ť for one layer, and is created by â€ś`linear_activation_forward()`â€ť.
5th and 6th are â€ś`linear_cache`â€ť created by `linear_forward`().

Thatâ€™s good, but also note that there are right and wrong ways to use â€śappendâ€ť. Note that it is a â€śmethodâ€ť of the `list` class, so using `append()` is not an assignment statement. If I have a list called `myList` and want to append a new element called `newElement`, the syntax is:

`myList.append(newElement)`

No equal signs involved!