Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

Home Forums Cody Bank Python Basic with Numpy Sigmoid Function

Viewing 0 reply threads
  • Author
    Posts
    • #260
      Abhishek TyagiAbhishek Tyagi
      Keymaster

      Before using np.exp(), you will use math.exp() to implement the sigmoid function. You will then see why np.exp() is preferable to math.exp().

      Exercise: Build a function that returns the sigmoid of a real number x. Use math.exp(x) for the exponential function.

      Reminder: sigmoid(x)=11+e−xsigmoid(x)=11+e−x is sometimes also known as the logistic function. It is a non-linear function used not only in Machine Learning (Logistic Regression), but also in Deep Learning.

      # GRADED FUNCTION: basic_sigmoid
      
      import math
      
      def basic_sigmoid(x):
          """
          Compute sigmoid of x.
      
          Arguments:
          x -- A scalar
      
          Return:
          s -- sigmoid(x)
          """
          
          ### START CODE HERE ### (≈ 1 line of code)
          s = 1 / (1 + math.exp(-x))
          ### END CODE HERE ###
          
          return s
      
      basic_sigmoid(4) #4 is an example
Viewing 0 reply threads
  • You must be logged in to reply to this topic.