3.1.4 · D5Neural Network Fundamentals

Question bank — Activation functions - sigmoid, tanh

1,601 words7 min readBack to topic

Quick symbol refresher so nothing here is unexplained:

  • = the input vector to the neuron — a list of numbers (features), e.g. , one number per incoming signal.
  • = the weight matrix (for a single neuron, a weight vector ): one number per input, controlling how strongly that input pushes the neuron.
  • = the bias, a single number added to shift the sum up or down regardless of the inputs.
  • = the pre-activation, the raw weighted sum a neuron computes before squashing — for one neuron this is . Any real number.
  • = sigmoid, squashes into .
  • = the activation = the output of the squasher for this neuron, i.e. . It is the number stored during the forward pass and reused later.
  • = hyperbolic tangent, squashes into .
  • = derivative = the local slope of the curve = how much the output moves per tiny nudge in . This slope is what Backpropagation multiplies by.
  • Saturation = the flat tails of the S-curve, where is very large positive or negative and the slope is nearly zero.

True or false — justify

TF1. "Sigmoid can output exactly 0 or exactly 1 for large enough input."
False — is always strictly positive, so approaches but never reaches or ; the range is the open interval .
TF2. "A network of 50 linear layers with no activation is more powerful than a single linear layer."
False — composing linear maps gives another linear map, so all 50 layers collapse into one ; the activation's nonlinearity is what breaks the collapse.
TF3. "Sigmoid outputs across several neurons in a layer form a valid probability distribution."
False — each sigmoid is independent and they do not sum to 1; for a distribution over mutually-exclusive classes you need Softmax.
TF4. "Tanh is just a sigmoid with a different label; the shapes are unrelated."
False — write , then , so tanh is a sigmoid stretched horizontally by 2 and scaled/shifted to span .
TF5. "The maximum slope of tanh is exactly four times the maximum slope of sigmoid."
True — differentiate by the chain rule: ; at this is versus , so the factor of 2 inside the argument produces the slope.
TF6. "Both sigmoid and tanh saturate, so both suffer from vanishing gradients in deep networks."
True — both have flat tails where the derivative , so chaining many layers multiplies many near-zero slopes and the gradient vanishes.
TF7. "Because tanh is zero-centered, it never causes vanishing gradients."
False — zero-centering fixes the sign-of-gradient zig-zag issue, not saturation; tanh still flattens in its tails and can vanish.
TF8. "Sigmoid's derivative requires recomputing during backprop."
False — the self-referential form reuses the already-computed forward activation , so no exponential is recomputed.
TF9. "Logistic regression is essentially a single sigmoid neuron."
True — Logistic Regression computes and reads it as a probability, which is exactly one sigmoid unit.
TF10. "The average output of a random-input sigmoid layer is near zero."
False — sigmoid outputs live in so their average is near (positive); tanh, centered on 0, is the one with near-zero average.

Spot the error

SE1. "Since and ranges over , the derivative can be as large as 1."
Writing the sigmoid value as , the product is maximized at , giving , not 1 — the derivative never exceeds anywhere.
SE2. "To get a probability that a sample belongs to one of 3 classes, apply sigmoid to each of the 3 outputs and you're done."
Three independent sigmoids don't normalize to sum 1; for mutually-exclusive classes you must use Softmax so the outputs form a proper distribution.
SE3. "Tanh maps to just like sigmoid."
Tanh maps to ; the negative range is precisely its zero-centered advantage over sigmoid's .
SE4. "We should use sigmoid in hidden layers because its probability interpretation helps learning."
The probability reading matters only at a binary output; in hidden layers sigmoid's all-positive, saturating behavior hurts training, which is why tanh or ReLU is preferred there.
SE5. ", so at large the slope grows because ."
At large , makes , so the slope shrinks (saturates), not grows.
SE6. "Making the network deeper always increases what sigmoid/tanh nets can learn."
Extra depth with saturating activations amplifies vanishing gradients, so deeper can actually train worse — a historical reason ReLU took over.
SE7. "All-positive sigmoid activations are fine because the weights can still be positive or negative."
The problem is that with all-positive inputs to a neuron, every gradient component of its weight vector shares the same sign, forcing inefficient zig-zag updates — independent of the weights' signs.

Why questions

WHY1. "Why can't we just use a step function (0 or 1) instead of the smooth sigmoid?"
A step has zero derivative almost everywhere and an undefined jump at 0, so backprop gets no usable slope; the smooth sigmoid provides gradients everywhere so the network can be nudged.
WHY2. "Why is the sigmoid's derivative largest at ?"
is the steepest point of the S-curve (output , the middle of ); away from it the curve flattens toward its horizontal asymptotes, so slope falls off.
WHY3. "Why does zero-centering (tanh) speed up hidden-layer training versus sigmoid?"
Zero-centered activations let a downstream neuron receive both positive and negative inputs, so its weight-gradient signs can differ, avoiding the shared-sign zig-zag that slows sigmoid-fed layers.
WHY4. "Why does the vanishing gradient get worse the deeper the network, not better?"
Backprop multiplies the per-layer slopes together; each saturated sigmoid contributes a factor , and multiplying many small factors drives the product exponentially toward 0.
WHY5. "Why is careful Weight Initialization tied to sigmoid/tanh?"
If initial weights make pre-activations large, neurons start in the flat saturated tails where slopes are tiny, so good initialization keeps near 0 where gradients are healthy.
WHY6. "Why do we write instead of treating them as separate functions?"
It shows tanh is a rescaled-shifted sigmoid, explaining why they share S-shape and saturation while differing only in centering and steepness — one insight instead of two memorized curves.
WHY7. "Why is a sigmoid output called a 'soft' version of firing?"
Instead of a hard yes/no it returns a continuous confidence in , so small changes in input produce small graded changes in output — 'soft' meaning smoothly graded rather than binary.

Edge cases

EC1. "What is and , and why do these anchor points matter?"
and ; these are the centers where each curve is steepest, so a fresh neuron with learns fastest.
EC2. "What happens to the gradient when for sigmoid?"
, so — a nearly dead slope, the vanishing-gradient tail in action.
EC3. "As , what do and approach?"
and ; the neuron is 'off' and its gradient dies, so it barely learns.
EC4. "As , what do and approach?"
and ; fully saturated 'on' with a vanishing slope.
EC5. "If two neurons both saturate — one at , one at — do their gradients differ in health?"
No; both tails are flat, so both have near-zero slope and both learn poorly regardless of which extreme they sit at.
EC6. "A sigmoid output neuron gives . What does that mean and is it a problem?"
It means maximum uncertainty (50/50), which is a perfectly valid — and gradient-healthy — state, not an error; it's exactly the steepest, most learnable point.
EC7. "What is the derivative of tanh at its center, and how does it compare to sigmoid's center slope?"
versus , so tanh is four times steeper at the origin, giving stronger gradients through the un-saturated region.

Connections

  • ReLU and Leaky ReLU — the non-saturating alternative that dodges most traps above.
  • Softmax — the correct tool when you catch yourself misusing sigmoid for multi-class.
  • Backpropagation — where every derivative fact here is actually consumed.
  • Vanishing and Exploding Gradients — the theme behind the edge-case tail questions.
  • Logistic Regression — the single-sigmoid special case.
  • Weight Initialization — the practical antidote to starting in the tails.