C2 W1 Excercise 2

I was working on exercise2 of this lab, but got stuck on building a dense layer subroutine.
Can someone help me out?

{mentor edit: code removed}

Quick Check

x_tst = 0.1np.arange(1,3,1).reshape(2,) # (1 examples, 2 features)
W_tst = 0.1
np.arange(1,7,1).reshape(2,3) # (2 input features, 3 output features)
b_tst = 0.1*np.arange(1,4,1).reshape(3,) # (3 features)
A_tst = my_dense(x_tst, W_tst, b_tst, sigmoid)
print(A_tst)

I got an output of [1. 1. 1.] but the expected output is
[0.54735762 0.57932425 0.61063923]

I tried a few times but still can’t get the expected output…

Thank you for your help!
Carolina

Nothing in the instructions tells you that you need to test for the type of activation function.

‘g’ is a function pointer. Not a text string.

You just use g(…) as-is. Nothing fancy.

Also, in the future, please don’t post your code on the forum. That’s not allowed by the Code of Conduct.

If a mentor needs to see your code, we’ll contact you with instructions.

Other tips:
Do not add the numpy import. That’s already done in the first cell in the notebook.

Do not add any code except inside the “START CODE HERE” area.

Every time you open the notebook, you have to run all of the cells. That is how the workspace is configured.

Hi TMosh,

Thank you for responding! Got it I will pay attention on posting code in the future.
How can I get help with a mentor about this problem?
I’m really stuck on this…

Thanks,
Carolina

I think I’ve already given you the necessary hints to fix the issue.
Read my first reply again.

Delete the if-test. It’s not needed.