Help with assignment

hey can someone help me with w4 assignment 1

What help do you need specifically?

Note: Please do not post your code here, but you can ask questions or post any error messages or asserts that you see.

Sure, we are here to help, but the thing to realize is that we can’t directly examine your notebooks. So as Tom says, you need to ask a specific question. Just saying (in effect) “I’m having a problem” doesn’t give us anything to go on.

All my codes are running great before the linear_activation_forward function, but I am getting an output error for this part.

Please show us the actual error that you are getting. Just “copy/paste” the output or take a screenshot and attach it to your reply using the “Up Arrow” tool. Just saying “I’m getting an error” is not useful. We need to know what the error actually is.


Interesting. The A values you show are actually correct. But there are two return values, right? Not just A, but also the cache value. So look at how you are handling the cache values.

I am using the linear_forward function in this .
Which has passed all the test cases before .

And for the activation cache , that is basically A right , so I think its not a problem of activation cache

Well, but you have to handle the return values correctly, right? You can’t modify that test cell, but I did “Insert Cell Below” and copied the code and added print statements to show the cache values:

t_A_prev, t_W, t_b = linear_activation_forward_test_case()

t_A, t_linear_activation_cache = linear_activation_forward(t_A_prev, t_W, t_b, activation = "sigmoid")
print("With sigmoid: A = " + str(t_A))
print(f"cache = {t_linear_activation_cache}")

t_A, t_linear_activation_cache = linear_activation_forward(t_A_prev, t_W, t_b, activation = "relu")
print("With ReLU: A = " + str(t_A))
print(f"cache = {t_linear_activation_cache}")


linear_activation_forward_test(linear_activation_forward)

When I run that, here’s what I get:

With sigmoid: A = [[0.96890023 0.11013289]]
cache = ((array([[-0.41675785, -0.05626683],
       [-2.1361961 ,  1.64027081],
       [-1.79343559, -0.84174737]]), array([[ 0.50288142, -1.24528809, -1.05795222]]), array([[-0.90900761]])), array([[ 3.43896131, -2.08938436]]))
With ReLU: A = [[3.43896131 0.        ]]
cache = ((array([[-0.41675785, -0.05626683],
       [-2.1361961 ,  1.64027081],
       [-1.79343559, -0.84174737]]), array([[ 0.50288142, -1.24528809, -1.05795222]]), array([[-0.90900761]])), array([[ 3.43896131, -2.08938436]]))
 All tests passed.

No, the activation cache is Z, right? Not A. But it is returned to you by the relu or sigmoid function, right? You don’t have to construct it: it is just given to you.

OK, Can you explain what exactly is linear cache and activation cache for this part ??
My understanding goes something like this :-

  1. linear_cache contains Z,W,b and is stored for the backward propagation part
    2)advanced_cache contains A[l] which goes as an input for the next layer

are this both correct ??

No, that’s wrong. The linear cache is one of the return values from linear_forward and it contains (A^{[l-1]}, W^{[l]}, b^{[l]}).

The activation cache just consists of Z^{[l]} and it is one of the return values from relu or sigmoid. You can examine the relu and sigmoid code by clicking “File → Open” and then reading the appropriate “utility” dot py file.

The high level point is that you don’t have to concern yourself with the contents of those cache values at this level: they are constructed for you by the lower level routines. You just have to take the return values and concatenate them. They even gave you that logic for the concatenation in the “template” code, right?

Ok , Thanks paulinpaloalto
I have got my codes correct now .

Thanks a lot , You have been a great help.