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

Linear Activation

The linear activation function simply returns its input unchanged. It's the simplest possible activation โ€” and understanding exactly why it's almost never used between hidden layers reinforces the core lesson from Linear Transformations.

Formula

\[ \phi(z) = z \]
PropertyValue
Range\((-\infty, \infty)\)
Derivative\(\phi'(z) = 1\) โ€” constant, everywhere

Graph

Output equals input exactly โ€” a straight line through the origin with slope 1.

Why It Can't Be Used Between Hidden Layers

This is the exact scenario proven in Linear Transformations: stacking layers that each use a linear activation collapses the entire network into a single linear transformation, regardless of depth. A 50-layer network with linear activations throughout has no more representational power than a single linear layer โ€” depth becomes completely wasted.

Where It Actually Is Used: Regression Output Layers

The one place a linear (identity) activation is standard is the output layer of a regression network โ€” where you want the raw, unbounded weighted sum as the final prediction (e.g. predicting a house price, which can be any positive real number, or even a temperature, which can be negative). Squashing this final output through a bounded activation like sigmoid or tanh would artificially cap what the network could ever predict.

Code

import torch.nn as nn

# Regression network: hidden layers use ReLU, but the OUTPUT layer uses no
# activation (equivalent to a linear/identity activation) -- this is standard practice
model = nn.Sequential(
    nn.Linear(10, 64), nn.ReLU(),
    nn.Linear(64, 32), nn.ReLU(),
    nn.Linear(32, 1)      # no activation here = linear output, suited to unbounded regression targets
)

Common Mistakes

  • Using linear activation on hidden layers "to keep things simple" โ€” this silently collapses the network's effective depth to 1 layer, wasting every parameter in the discarded layers.
  • Forgetting that not specifying an activation after a layer in most frameworks (like the final nn.Linear above) is exactly a linear/identity activation โ€” it's an intentional choice for regression outputs, not an oversight.

Interview Relevance

Q: "Why does a regression model's final layer typically have no activation function, or a linear one?" Because the target values (e.g. price, temperature) are unbounded real numbers. A bounded activation like sigmoid (range 0โ€“1) or tanh (range -1โ€“1) would make it mathematically impossible for the network to ever predict values outside that range, regardless of training.

Practice Question

Explain why a 4-layer network using only linear activations throughout is mathematically equivalent to a network with just 1 linear layer.

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

Linear Activation โ€“ FAQs

Quick answers about learning Linear Activation in Deep Learning.

This free note from CodingNow 2.0 explains Linear Activation 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 Linear Activation, is 100% free with no signup required.
With focused practice, most students grasp Linear Activation 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