#189Vanishing gradients through sigmoid layersEasyNeural NetworksActivation FunctionsCalculus
Vanishing gradients through sigmoid layers
Background
Backprop multiplies a sigmoid slope at every layer. Since always, multiplying many of them together drives the product toward zero — the vanishing gradient problem that makes deep sigmoid stacks hard to train.
Problem statement
Implement gradient_product(activations) returning the product of the sigmoid slopes across a chain of layer activations.
Input
activations— array-like of sigmoid activations (one representative value per layer), each in .
Output
Returns a Python float: .
Examples
Example 1 — one layer at its steepest
Input: activations = [0.5]
Output: 0.25
Explanation: , the maximum possible per-layer slope.
Example 2 — three layers
Input: activations = [0.5, 0.5, 0.5]
Output: 0.015625
Explanation: — already 16× smaller after three layers.
Constraints
- Compute per layer, then take the product.
- Return a plain
float.
Notes
- Because every factor is , an -layer sigmoid path attenuates the gradient by at least — which is why ReLU (slope 1 for ) replaced sigmoid between hidden layers.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Example: one layer at the steepest point
- •Reference: three layers of 0.5 shrink to 0.25^3
- •Sample: two asymmetric activations