Python Code to Calculate the Derivative of Sigmoid Activation Function

by keshav


In this article, we will look at the python function to calculate the derivative of the sigmoid activation function.

Sigmoid Activation Function is one of the widely used activation functions in deep learning. As its name suggests the curve of the sigmoid function is S-shaped.


Sigmoid transforms the values between the range 0 and 1.


The Mathematical function of the sigmoid function is:

sigmoid activation function

In python, we can create a sigmoid activation function as,

# Sigmoid Activation Function
def sigmoid(x):
  return 1/(1+np.exp(-x))

Derivative of the sigmoid is:

derivative sigmoid function

In Python, we can obtain the derivative of the activation function as,

# Derivative of Sigmoid
def der_sigmoid(x):
  return sigmoid(x) * (1- sigmoid(x))

Let us see the plot for both the Sigmoid activation function and its derivative.

sigmoid activation function and derivative

to read more about activation functions - link

No Comments

Post a Comment