Sigmoid(Logistic) Activation Function ( with python code)

by keshav


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

Derivative of the sigmoid is:

derivative sigmoid function

Also Read:

Python Code


import numpy as np
import matplotlib.pyplot as plt

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

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

# Generating data to plot
x_data = np.linspace(-10,10,100)
y_data = sigmoid(x_data)
dy_data = der_sigmoid(x_data)

# Plotting
plt.plot(x_data, y_data, x_data, dy_data)
plt.title('Sigmoid Activation Function & Derivative')


sigmoid activation function and derivative


to read more about activation functions - link


No Comments

Post a Comment