liveBook · Manning

Sigmoid

As explained in Grokking AI Algorithms, Second Edition

A sigmoid function is a bounded S-shaped mathematical function that maps real-valued inputs to values between two limits, commonly zero and one.

A sigmoid is an activation function that squashes any input into an S-shaped curve between 0 and 1. Think of it as a dial: changing the input changes the output smoothly, rather than flipping it straight from off to on. That makes the output useful when a neural network predicts a probability. section 9.2

Figure 9.7 The sigmoid function
09_07

The curve shows both the smooth middle and the nearly flat ends. section 9.2

From inputs to a collision prediction

In a collision-prediction network, each hidden node first adds its weighted inputs, then applies sigmoid to that sum. The output node repeats the weighted-sum-and-sigmoid process using the hidden nodes’ results. One resulting prediction is 0.00214, interpreted as a 0.214% chance of collision. section 9.4

Sigmoid also helps a network learn nonlinear relationships. Its drawback is at the extremes: the curve becomes almost flat, so its slope approaches zero and learning can slow or stop. This is the vanishing-gradient problem. A step function gives an exact 0 or 1 instead, while other activation functions offer different learning behavior. section 9.10 section 9.2

def sigmoid(x):
   return 1 / (1 + np.exp(-x))

def sigmoid_derivative(x):
   return sigmoid(x) * (1 - sigmoid(x)) #A

The short NumPy listing implements sigmoid and the derivative used when backpropagation adjusts weights. section 9.9

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Walks through layer-by-layer activation and implements sigmoid and its derivative for backpropagation.
Examples
Uses a collision prediction of 0.00214 and a loan-decision network with sigmoid hidden layers and a step-function output.
What it assumes
Builds on weighted inputs and neuron activations; uses NumPy operations for the implementation.
What you can do after
Build it from scratch in NumPy for forward propagation and derivative-based weight updates.
How it connects
Connects activation functions to forward propagation, backpropagation, nonlinear learning, and vanishing gradients.

Also explained in

Compare how 16 books explain sigmoid →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.