Please explain this-

[snippet removed by mentor]

  1. can anyone tell me what’s wrong here.
  2. what is meaning of “sigmoid_derivative_test(sigmoid_derivative)”.
    3.why we are typecasting to string here "print (“sigmoid_derivative(t_x) = " + str(sigmoid_derivative(t_x)))”/
  1. Please read up on callable. The computation of the derivative involves performing a mathematical operation that doesn’t unvolve calling the sigmoid directly. So, please fix your code.
  2. The sigmoid_derivative_tests takes a reference to the sigmoid_derivative function which it an internally invoke to check for correctness of implementation of the function. If you have background in C, think of it as a function pointer. Do keep in mind that this specialization assumes working knowledge of python. Moving forward without an understanding of the basics is not a good idea. That said, there are plenty of online and coursera tutorials that cover enough python required for this specialization.
  3. Addition with respect to string requires the right of + operator to be a string as well. Here’s an example of why you need str:
>>> "hello" + 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "int") to str
>>> "hello" + str(1)
'hello1'

Note that the “ndarray is not callable” error message is caused by this expression in your code:

s(1 - s)

This is one of the many cases in which math notation is different than programming languages. What that means in python is that s is a function and you are calling it with the argument (1 - s). If what you intended was to multiply those two quantities, the syntax for that in python is:

s * (1 - s)

As Balaji says, reasonable knowledge and experience with python is a prerequisite here. :nerd_face:

1 Like

Yeah, but easy to make the silly mistake of coding s(1 - 2) in my opinion even if you’re a little rusty on Python but not completely ignorant. Thanks so much for clarifying this. Balaji’s reply was detailed without being of much help.