ReLU and its variants: trace a stopped unit
ReLU 及其变体
Compare exact bias-only and learned-slope updates, explicit corner conventions and the limits of nonzero local gradients.
reluWhen a unit stops responding to its training data
A unit predicts 1, but its preactivation is−1. If it uses ReLU, its output is 0 and its local input slope is 0. A loss can say “increase the output” while the activation passes no gradient back to the bias. This is one mechanism behind a dead ReLU: the unit stays on its inactive side for all relevant training inputs.
“Dead” is a statement about inputs and updates, not just one negative number. A unit inactive on one example can be active on another. Other parameters, changing upstream features, momentum or a different update rule can move it. Our demonstration deliberately isolates a bias-only unit with fixed input so that the obstruction can be proved.
Deep Learning, Sections 6.3–6.3.1 discusses rectified units and derivative conventions. He and colleagues, ICCV 2015, Section 2.1 defines PReLU and its learned negative-side slope. Read artificial neurons before tracing the updates below.
Fixed and learned slopes are different choices
Write a rectifier with negative-side slope α as:
ReLU fixes α=0. Leaky ReLU fixes a small positive α, often between 0 and 1. PReLU learns α as a parameter, possibly per channel or shared across a layer. The cited PReLU paper does not impose our leaky interval as a universal constraint on the learned slope. If α becomes negative, the negative branch has negative slope and can produce positive outputs.
At zero the ordinary derivative is undefined unless α=1, because the left and right slopes differ. Our program uses the left slope α as its backward convention, giving 0 for ReLU. For 0≤α≤1, this is an endpoint of the convex subgradient interval[α,1]. If α is negative the function remains convex, but monotonicity is lost; if α exceeds 1 this convex-subgradient description no longer applies. Exact zeros can arise through cancellation or initialization, so the convention must be explicit.
A loss gradient that cannot reach the bias
Set preactivation z=b, target 1, and use half squared error. On the negative branch:
With b=−1 and α=0, the bias gradient is 0 although the loss is 1/2. Bias-only gradient descent never leaves b=−1. With fixed α=1/4, the initial output is−1/4, the loss 25/32 and the bias gradient−5/16. This leaky unit initially has a larger loss, yet it receives a direction that can improve the prediction.
For learning rate 1, a bias-only step on the negative branch is:
The positive-branch formula follows because there L=(b−1)²/2. At fixed α=1/4 the iterates eventually cross zero, then reach 1. On each side the loss is quadratic, but its derivative jumps at zero for this target and slope. A smooth global descent bound cannot be applied across that corner. The program checks that the actual finite sequence decreases the loss, including its crossing step.
Alternatively freeze b=−1 and learn α. Initially ∂L/∂α=5/4. A slope-only step with rate 1/4 changes α from 1/4 to−1/16, output from−1/4 to 1/16, and loss to 225/512. This is a different parameter update. It can fit a positive target while the preactivation remains negative; calling that a “revived positive branch” would be wrong.
Compare the two update paths exactly
This complete Python 3.12 example uses rational arithmetic. It runs bias-only descent for ReLU and a fixed leaky slope, then separately performs the slope-only PReLU update. No random seed, framework or training dataset is required for this one-point model.
from fractions import Fraction as F
def objective(bias, alpha):
if any(type(v) not in (int,F) or abs(v)>1000 for v in (bias,alpha)):
raise ValueError('bounded rational bias and slope required')
bias=F(bias);alpha=F(alpha)
active=bias>0
value=bias if active else alpha*bias
slope=F(1) if active else alpha
residual=value-1
return value,residual*residual/2,residual*slope,residual*min(bias,0)
def fit_bias(alpha, steps=20):
if type(steps) is not int or not 0<=steps<=20:
raise ValueError('zero to 20 steps required')
objective(-1,alpha);b=F(-1);history=[b]
for _ in range(steps):
b-=objective(b,alpha)[2]
history.append(b)
return history
if __name__=='__main__':
for alpha in (F(0),F(1,4)):
path=fit_bias(alpha)
first=next((i for i,b in enumerate(path) if b>0),None)
print('fixed slope:',alpha,'first positive bias step:',first,
'final bias:',f'{float(path[-1]):.6f}','loss:',f'{float(objective(path[-1],alpha)[1]):.6f}')
value,loss,db,da=objective(F(-1),F(1,4))
print('initial value/loss/db/da:',value,loss,db,da)
new_alpha=F(1,4)-F(1,4)*da
print('slope-only PReLU step: alpha',new_alpha,'value/loss',*objective(-1,new_alpha)[:2])
Actual output:
fixed slope: 0 first positive bias step: None final bias: -1.000000 loss: 0.500000
fixed slope: 1/4 first positive bias step: 4 final bias: 1.000000 loss: 0.000000
initial value/loss/db/da: -1/4 25/32 -5/16 5/4
slope-only PReLU step: alpha -1/16 value/loss 1/16 225/512
Each step costs constant rational arithmetic; numerator and denominator bit sizes can grow. The 20-step cap keeps the demonstration small. Tests verify the literal gradients and PReLU update, the inactive ReLU invariant, monotone loss along the leaky path and finite differences away from the corner.
Try changing the starting bias or fixed slope while keeping the learning-rate assumptions visible. Do not compare only final error: trace whether a unit receives gradients, whether its preactivation changes sign, and which parameters were allowed to move.
A nonzero activation slope does not guarantee learning
A leaky slope removes this particular zero local derivative. The complete gradient can still vanish because of a zero upstream signal, a zero input or cancellation across examples. Larger steps can cross regions and destabilize a network. A learned PReLU slope can also approach zero or take values that change the geometry.
ReLU is not bounded above and its responses need not have zero mean. Initialization and feature scale matter; see the planned He initialization. Sparsity of positive activations is an observed property on chosen inputs, not a guarantee that every fitted network is sparse or interpretable.
Our tiny bias fit demonstrates a mechanism, not an architecture benchmark. The original paper’s ImageNet comparison has a particular model, training schedule and evaluation protocol. It does not prove that learning the slope improves every task, and its phrase about human performance should not be read as general human-level vision.
Which parameter is allowed to escape?
- Why does bias-only ReLU descent remain at b=−1 in this example?
Answer 1: Every step sees the negative branch with chosen derivative 0, so the bias gradient stays 0.
- What is the first leaky bias update for α=1/4 and learning rate 1?
Answer 2: b becomes−11/16 because the initial gradient is−5/16.
- With b fixed at−1, what does the slope-only step with rate 1/4 produce?
Answer 3: α=−1/16, output 1/16 and loss 225/512. The preactivation stays negative.
- Does a positive leaky slope make every network parameter gradient nonzero?
Answer 4: No. Other factors and summation in the chain rule can still make the complete gradient zero.
Inspect the failure before choosing a variant
The textbook supplies the rectifier framework; the original PReLU paper supplies the learned-slope definition and derivative. The exact update paths here are original teaching experiments. They intentionally distinguish fixed slope, bias learning and slope learning.
Continue with GELU and SiLU for smooth, nonmonotone alternatives, and gradient checking for checks that respect corners. A centered difference crossing zero measures a secant, not ReLU’s nonexistent ordinary derivative there.
Make a prediction, then check
With b fixed at−1, the worked PReLU slope update gives which output?
Learning objectives
- Distinguish fixed and learned slopes and corner conventions.
- Trace an inactive unit under specified parameter updates.
Prerequisites & connections
Explore related knowledge →References
- Deep Learning — Chapter 6: Deep Feedforward Networks
Ian Goodfellow; Yoshua Bengio; Aaron Courville · 2016 - Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification
Kaiming He; Xiangyu Zhang; Shaoqing Ren; Jian Sun · 2015
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-06 · Codex single-agent authored technical review: cited primary-source scope, explicit assumptions, original calculations and counterexamples, runnable tests and bilingual review; not independent human or second-agent review.
- Single-agent authored technical review: bounded primary-source locations, assumptions, original derivations, exact/literal references and matching bilingual equations/examples/exercises. Not independent human or second-agent review.
- Four focused CPython3.12.4 tests passed per chapter. Rectifier update paths, smooth-gate moments/stationary points, batch intermediates and weighted Bernoulli optima are checked against literal references, analytic identities and finite differences. Forward-pass example uses pinned NumPy1.26.4; other examples use the standard library.
- Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
- Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.
Source locations checked:
- Deep Learning — Chapter 6: Deep Feedforward Networks · Chapter6 Sections6.3–6.3.1, printed187–189, one-sided derivatives and fixed/learned rectifier slopes.
- Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification · ICCV2015 Section2.1, physicalpage2: PReLU definition, slope derivative and channel sharing; no benchmark reproduced.
Related topics