# Course 1 week 4 assignment 1 exercise 5

hello,
I do not know what parameters should I choose here. Do you have any idea ?

AL, cache = linear_activation_forward(A, ?, ?, ‘sigmoid’)

1 Like

Have you looked at the definition of the function linear_activation_forward and what happens within that function? That should give you some clues. It might also be worth reading through the instructions again for the L_model_forward section.

I think i shoud use parameters[‘w2’] and parameters[‘b2’] but then I have this error

AL = [[0.90589057 0.75020632 0.05200643 0.82351754]
[0.99823392 0.08462048 0.01610661 0.98885794]
[0.9999688 0.33941221 0.83703792 0.99971951]]
Error: Wrong shape for variable 0.
Error: Wrong shape for variable 0.
Error: Wrong shape for variable 1.
Error: Wrong shape for variable 2.
Error: Wrong shape for variable 1.
Error: Wrong output for variable 0.
Error: Wrong output for variable 0.
Error: Wrong output for variable 1.
Error: Wrong output for variable 2.
Error: Wrong output for variable 1.
1 Tests passed
2 Tests failed

Is it possible to share my code?

Yes, you need to extract the appropriate W^{[l]} and b^{[l]} values from the parameters dictionary. But it’s not always for layer 2, right?

Please show us the whole output of the test, e.g. so that we can see the function invocation as well.

Here’s a thread which shows the “dimensional analysis” for the 2hidden test case here.

Note that the shape of your AL (which is A3 in this case) is 3 x 4, but it should be 1 x 4. If you study that “dimensional analysis” thread, you’ll see that A2 is legitimately 3 x 4. So how did your A3 end up with the same shape as A2? That’s the question you need to answer. Most likely it is something to do with how you handle that last layer: that’s the one that’s handled after you fall out of the loop over the hidden layers, right?

Can you tell me what is wrong here ?

{moderator edit - solution code removed}

I have changed the last line: str(l) to str(l+1) but still no answer.

operands could not be broadcast together with shapes (1,4) (1,3)

Oh, I realized the mistake. I had used w2 instead of b2.