3.1.4 · D3Neural Network Fundamentals

Worked examples — Activation functions - sigmoid, tanh

2,036 words9 min readBack to topic

Before we start, three symbols we will lean on, each in plain words:

Figure — Activation functions -  sigmoid, tanh

Look at the figure. The orange curve (sigmoid) never dips below or above . The teal curve (tanh) is the same shape stretched to live between and . The flat tails on both far left and far right are where trouble hides — we will land there in cell E.


The scenario matrix

Every case sigmoid/tanh can throw at you falls into one of these cells. Each later example is tagged with its cell letter.

Cell Case class What makes it special Example
A (positive input) output above the midpoint Ex 1
B (negative input) output below the midpoint; symmetry test Ex 2
C (exact zero / degenerate) the crossing point; max slope Ex 3
D Backprop use of the slope derivative multiplied into a chain Ex 4
E $ z $ large (saturated tail / limit)
F Sigmoid vs tanh on the SAME zero-centering, 4× slope Ex 6
G Real-world word problem reading output as a probability Ex 7
H Exam twist (inverse / solve for ) going backwards through Ex 8

We will hit all eight.


Example 1 — Cell A: positive pre-activation


Example 2 — Cell B: negative pre-activation & the symmetry law

Recall Why does

? Multiply top and bottom of by : you get . One-line proof ::: .


Example 3 — Cell C: the degenerate input


Example 4 — Cell D: the slope inside backpropagation


Example 5 — Cell E: the saturated tail & vanishing gradient (limit)


Example 6 — Cell F: sigmoid vs tanh on the same input


Example 7 — Cell G: real-world word problem


Example 8 — Cell H: exam twist (invert the sigmoid)


Coverage check

Recall Did we hit every cell of the matrix?

A (Ex 1, ), B (Ex 2, + symmetry), C (Ex 3, degenerate + max slope), D (Ex 4, backprop chain), E (Ex 5, saturated limit / vanishing gradient), F (Ex 6, sigmoid vs tanh + link), G (Ex 7, word problem), H (Ex 8, inverse/logit). All eight ✓.


Connections