C1_W3_UNQ_C2_Compute_Cost

Hello! I’ve had several problems with my assignment.
First of all sigismoid function test with array didn’t work since a first try, even though with scalar i was inputing it did.
showing this error
sigmoid([ -1, 0, 1, 2]) = [0.73105858 0.5 0.26894142 0.11920292]

AssertionError Traceback (most recent call last)
in
3 # UNIT TESTS
4 from public_tests import *
----> 5 sigmoid_test(sigmoid)

~/work/public_tests.py in sigmoid_test(target)
3
4 def sigmoid_test(target):
----> 5 assert np.isclose(target(3.0), 0.9525741268224334), “Failed for scalar input”
6 assert np.allclose(target(np.array([2.5, 0])), [0.92414182, 0.5]), “Failed for 1D array”
7 assert np.allclose(target(np.array([[2.5, -2.5], [0, 1]])),

AssertionError: Failed for scalar input

some outputs are matching the expected though.

Next i had much more difficulties with computing the cost, mixed up indention, but i have a thought maybe a big restart could help but dont know how to perform it in Jupiter. I would really like someone taking a look into my code and helping me with the restart.

I think maybe my code is affected by something what’s wrong with the sigismoid function not only indentation and the values after many tries are not suiting the solution.

Hope to sort it out soon,
Many thanks!

Your sigmoid function doesn’t work when the ‘z’ parameter is a scalar.
When the value 3.0 was applied, the result was not the correct value.

If there is a problem with your notebook, the most you should have to do is restart the kernel, then run all the cells again.
The procedure is:

  • Kernel → Restart & Clear Output.
  • Cell → Run All

If there is a problem with your code, I next have to ask whether you have Python programming experience?

1 Like

The sigmoid function requires only one line of code, and that line includes the np.exp() function, along with a couple of simple math operators.

The line of code must be indented one level from column 1, so that it lines up with the doctext and the “return g” statement.