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:
Derivative of the sigmoid is:
Also Read:
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')
plt.legend(['sigmoid','der_sigmoid'])
plt.grid()
plt.show()
Post a Comment
No Comments