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 alist
, you can uselist.append(c)
.
Yes, this sounds like DLS C1 W4 A1. I used the little “edit pencil” on the title to move it to the correct category.
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!