Let us visualize the Sigmoid Function. We know the function for it and the range of the output.
So, let's get started.
# Import Dependencies
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
Now, let's create a dummy data. I will be using Numpy's inbuilt function with following format
to generate input data. So, let's do it.
# Generate dummy data
X = np.arange(-10.0, 10.0, 0.2)
print('X: ',X)
So, we got our values in the range -10 and +10 with a step size of 0.2. Now to define the sigmoid function.
# Sigmoid Function
# sigmoid(x) = 1 / (1 + exp(-x))
def sigmoid(x):
return (1.0/(1 + np.exp(-x)))
So, we are all done. Let's plot our sigmoid function.
f_X = sigmoid(X)
# Plot Sigmoid Function
fig,ax = plt.subplots(figsize = (10,8))
ax.plot(X,f_X)
ax.set_xlabel('Z')
ax.set_ylabel('label = 0 or 1')
ax.set_title('Sigmoid Function')
So, we can clearly see that for any values of input, this function converts the value to the range of 0 and 1.