DLS Course-1, Week 4, Exercise 8

I am not able to understand how to overcome this error

This error means that the cashe tuple contains only 2 values but you need 3. So check where the tuple is computed to fix the issue.

{moderator edit - solution code removed}

but no error was raised in the “relu” linear_backward function call and even the cache is coded correctly

The error points at linear_backward that is not producing 3 values

{moderator edit - solution code removed}

this is my linear_backward function which is returning 3 values correctly used by “relu”

A perfectly correct function can still throw errors if you pass it incorrect arguments. Your linear_activation_backward code is wrong. You are passing the wrong cache argument to linear_backward. You are passing the full cache entry, but it should be the linear cache portion. They gave you the code to extract the activation cache and linear cache from the full cache.

Also note that it’s against the course rules to just post your code and say, in effect, “Please fix it for me”. Please see the Honor Code in Week 2.

1 Like

You can figure out the structure of the cache entries by examining the forward propagation code. It’s all there for you to see. At each layer, you get this structure as the cache entry:

((A, W, b), Z)

So that is a 2-tuple. The first element of the 2-tuple is a 3-tuple. The second element of the 2-tuple is a single value.

The reason you get the error about “expected 3 entries, but got 2” is that you passed the full 2-tuple entry, when you should have passed just the first 3-tuple.

1 Like

Thanks a lot Sir!

I am really very sorry for defaulting over the Honor Code, and will make sure that it never gets repeated.

Thanks to the discussion here I was able to resolve the similar error I was getting.

Can someone elaborate on what the linear cache and the activation cache are in cache? Linear cache if I understand correctly is saved in forward propagation and stores W and b. What is activation cache saving? output of activation of (W,b)? I also don’t undertand the dimensions.

Can someone explain further?

Thanks

The code that generates the caches is all there in the forward propagation logic. We already wrote that. Please go back and have a look at that code and it should all become clear.