3.1.4 · D4Neural Network Fundamentals

Exercises — Activation functions - sigmoid, tanh

2,695 words12 min readBack to topic

We use only two functions the whole way down. Let us restate them so nothing is assumed:

Figure 1 — the two squashers. Study this before Level 1; it is the geometry behind Levels 1–2.

Figure — Activation functions -  sigmoid, tanh

Look at Figure 1: the blue curve () lives between the two dashed lines and ; the yellow curve () lives between and and passes exactly through the origin. Later, Figure 2 (placed just before Level 5) draws the two derivative humps — refer to it when a solution mentions the " hump" or " hump".


Level 1 — Recognition

Recall Solution L1-Q1

What we check: the range (set of possible outputs) of each function. Read it off Figure 1: the blue curve stays entirely above the dashed line at ; the yellow curve dips below on its left half.

  • — always positive, never reaches or .
  • — can be negative for . Answer: only can be negative. Range of sigmoid is ; range of tanh is . Why the open brackets? Because is never exactly (an exponential is always strictly positive), so can approach but never touch — and similarly for the other bounds.
Recall Solution L1-Q2

At : .

  • .
  • . Check against Figure 1: the blue dot marks and the yellow dot marks — exactly the two values we just computed. Answer: , . These are exactly the midpoints of their ranges — the "meh, undecided" point of each dimmer switch.

Level 2 — Application

Recall Solution L2-Q1

Plug in: . Do the division by hand. We want . Multiply a trial value: , a touch under ; , a touch over. So the answer sits between and . Interpolating, of the gap per thousandth, giving about more: . Why round to 4 places? The inputs were given to 6 significant figures; carrying more than 4 decimals in the output would claim precision the inputs do not support, so 4 decimals () is the honest stopping point. Locate it on Figure 1: at the blue curve is already high, hugging the upper dashed line near — consistent with . Answer: . The neuron "fires" at about 88% confidence.

Recall Solution L2-Q2

Step 1 — pre-activation (weighted sum): Why? The dot product multiplies each weight by its matching input and adds them, then the bias shifts the total. Step 2 — apply tanh: Answer: , .

Recall Solution L2-Q3

Why this route? The identity says tanh is a stretched, shifted sigmoid; checking it two ways guards against arithmetic slips. Step 1: , so . Step 2: . Answer: — matches Q2. The identity holds.


Level 3 — Analysis

Recall Solution L3-Q1

Use the self-referential derivative: . Form the ratio . Answer: ; it is approximately 14 times smaller than . Confirm this visually on Figure 2 (the derivative-hump figure before Level 5): the green curve peaks at over and has nearly flattened to the axis by . Out on that flat tail a nudge in barely moves the output, so backprop passes almost no signal — the vanishing-gradient effect from Vanishing and Exploding Gradients.

Recall Solution L3-Q2

Chain rule (from the recap): the loss depends on through the activation , so multiply the incoming slope by the local slope: Answer: . Even a healthy upstream gradient of is choked down to by the tiny local slope — one saturated layer already loses ~98% of the signal. See Backpropagation.

Recall Solution L3-Q3

Compute: Both negative. Because are forced positive (sigmoid range — the entirely-above-zero blue curve in Figure 1), the sign of every weight gradient equals the sign of the single shared . So all weights are pushed the same direction each step → the "zig-zag" inefficiency. Answer: and ; same sign. This is exactly why zero-centered (which can output negatives) trains hidden layers more smoothly.


Level 4 — Synthesis

Recall Solution L4-Q1

First, why we may swap variable from to . We claim is strictly increasing, so each maps to exactly one and vice versa. Justification: ; since (from L1-Q1), both factors and , so their product for every real . A function with a strictly positive slope everywhere is strictly increasing — hence a genuine one-to-one correspondence between and . Maximizing the slope over is therefore the same as maximizing it over . Reframe: the slope is where ranges over . Maximize : . Second derivative , so it's a maximum. Translate back: means , which happens at . There . See it: this is exactly the peak of the green hump in Figure 2, sitting at . Answer: max slope at . ∎

Recall Solution L4-Q2

Differentiate the identity using the chain rule from the recap. The outer function multiplies by ; the inner function is , whose derivative is — so that inner gets pulled out front (this is the factor): Evaluate at : , so See it: in Figure 2 the red hump peaks at , exactly four times higher than the green peak at . Answer: — and the "" factor is now explained: it's precisely the two chain-rule factors of 2 multiplying .

Recall Solution L4-Q3

Invert sigmoid. From : Slope check: Answer: , slope . The function that undoes sigmoid is called the logit — the backbone of Logistic Regression.


Level 5 — Mastery

Figure 2 — the derivative humps. Use this for the symmetry arguments in Level 5 (and the L3/L4 references above).

Figure — Activation functions -  sigmoid, tanh

The green hump is : notice it is a mirror-symmetric bell peaking at over , with the two marked points at sitting at equal height — the picture of the L5-Q3 result. The red hump () peaks four times higher at .

Recall Solution L5-Q1

Start from the definition: Multiply top and bottom by (a legal move, ): Interpretation (look at Figure 1): reflect the input across and the output reflects across — the blue curve has point symmetry about the marked dot , confirming the L1 trap that it is not symmetric about the origin.

Recall Solution L5-Q2

From the definition, replace by : Factor out of the numerator and note the denominator is unchanged (addition is commutative, so ): Connection (see the yellow curve in Figure 1): oddness means the curve has point symmetry about the origin, so for symmetric inputs the outputs are balanced positive/negative — their average sits at . That is exactly the "zero-centered" property that avoids the same-sign gradient zig-zag of L3-Q3.

Recall Solution L5-Q3

Symbolic proof. Differentiate the identity . On the left, the chain rule (recap) applies to : outer slope times inner slope , giving . On the right, . Equate: So the slope is an even function — a bell-shaped hump centered at , its peak . Numeric check. At , so . By symmetry should also be : indeed , giving . ✓ Answer: both equal — the two green square markers at in Figure 2 sit at the same height , the picture of this result.


Connections