๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #78

ReLU vs Leaky ReLU

This comparison note settles the most common practical activation-function question: when does the small extra complexity of Leaky ReLU actually earn its keep over plain ReLU?

Side-by-Side Comparison

ReLULeaky ReLU
Formula for \(z<0\)0\(\alpha z\) (small \(\alpha\), e.g. 0.01)
Gradient for \(z<0\)Exactly 0\(\alpha\) (small but non-zero)
Dying neuron riskReal โ€” a neuron can get permanently stuck outputting 0Much lower โ€” negative inputs still produce a (small) gradient
Extra hyperparametersNoneOne (\(\alpha\))
Computational costSlightly cheaperSlightly more (one extra multiplication for negative inputs)
Common defaultYes โ€” still the most common starting choiceUsed when dying neurons are observed to be a real problem

When the Difference Actually Matters

In practice, the gap between ReLU and Leaky ReLU is often small โ€” many well-regularized, well-initialized networks trained with ReLU don't suffer significant dying-neuron issues. The difference matters most when: learning rates are aggressive (increasing dying-neuron risk), the network is very deep (more opportunities for neurons to die somewhere), or you empirically observe a large fraction of dead neurons (near-zero activation for most/all inputs) during training diagnostics.

Code โ€” Comparing Their Behavior

import torch
import torch.nn as nn

relu = nn.ReLU()
leaky = nn.LeakyReLU(negative_slope=0.01)

z = torch.tensor([-10.0, -1.0, 0.0, 1.0, 10.0])
print("ReLU:      ", relu(z))
print("LeakyReLU: ", leaky(z))
# ReLU:       tensor([ 0.,  0.,  0.,  1., 10.])
# LeakyReLU:  tensor([-0.1000, -0.0100,  0.0000,  1.0000, 10.0000])

Common Mistakes

  • Switching to Leaky ReLU reflexively without evidence of a dying-neuron problem โ€” it's a reasonable default-adjacent choice, but the added hyperparameter and marginal compute cost aren't automatically worth it without a specific reason.
  • Assuming Leaky ReLU completely eliminates the possibility of near-dead neurons โ€” a very small \(\alpha\) still means a very small gradient; it reduces but doesn't fully remove the risk of slow learning for consistently-negative neurons.

Interview Relevance

Q: "When would you specifically choose Leaky ReLU over plain ReLU?" When training diagnostics show a significant fraction of dead neurons (activations stuck at exactly zero across most/all training examples), often correlated with a high learning rate or very deep architecture. In the absence of that specific evidence, plain ReLU remains a reasonable, simpler default.

Practice Question

A network trained with ReLU shows that 40% of neurons in one layer output exactly 0 for every example in the validation set. What does this suggest, and what's one activation-function-level fix you could try?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

ReLU vs Leaky ReLU โ€“ FAQs

Quick answers about learning ReLU vs Leaky ReLU in Deep Learning.

This free note from CodingNow 2.0 explains ReLU vs Leaky ReLU in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including ReLU vs Leaky ReLU, is 100% free with no signup required.
With focused practice, most students grasp ReLU vs Leaky ReLU in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now