Apply the Sigmoid Function

Learn how to use the sigmoid function to calculate the outputs of the hidden and final layers.

Sigmoid function in scipy

Here’s the formula of the sigmoid function:

Ohidden=sigmoid(Xhidden) O_\text{hidden} = \text{sigmoid}( X_\text{hidden} )

This should be easy, especially if the sigmoid function is already defined in a Python library. It turns out that it is. The scipy library has a set of special functions, and the sigmoid function is called expit(). This library is imported, just like we imported the numpy library:

Get hands-on with 1400+ tech skills courses.