Getting started with the logistic function

Let's start with introducing the logistic function (which is more commonly called sigmoid function) as the algorithm core before we dive into the algorithm itself. It basically maps an input to an output of values between 0 and 1. And it is defined as follows:

We can visualize it as follows:

First define the logistic function:

>>> import numpy as np
>>> def sigmoid(input):
... return 1.0 / (1 + np.exp(-input))

Input variables from -8 to 8, and the output correspondingly:

>>> z = np.linspace(-8, 8, 1000)
>>> y = sigmoid(z)
>>> import matplotlib.pyplot as plt
>>> plt.plot(z, y)
>>> plt.axhline(y=0, ls='dotted', color='k')
>>> plt.axhline(y=0.5, ls='dotted', color='k')
>>> plt.axhline(y=1, ls='dotted', color='k')
>>> plt.yticks([0.0, 0.25, 0.5, 0.75, 1.0])
>>> plt.xlabel('z')
>>> plt.ylabel('y(z)')
>>> plt.show()

The plot of the logistic function is generated as follows:

In the S-shaped curve, all inputs are transformed into the range from 0 to 1. For positive inputs, a greater value results in an output closer to 1; for negative inputs, a smaller value generates an output closer to 0; when the input is 0, the output is the midpoint 0.5.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.191.134