esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

Why Do Neural Nets Need Non-Linearity?

Why stacked linear layers are not enough, what an activation function does, and how ReLU, sigmoid and tanh differ, explained for your AI interview.

In short

Without a non-linear step between layers, a stack of layers is just one linear formula, so extra depth adds nothing. An activation function such as ReLU adds the bend that lets a network learn curves, thresholds and combinations of inputs.

9 min readBeginnerCommon · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Without a non-linear step between layers, stacking layers in a neural network adds no real power. Two linear layers collapse into one linear formula. An activation function, such as ReLU, adds the bend that lets each layer build a new shape from the last. With that bend, the network can learn thresholds, curves and combinations of inputs.

What is non-linearity, in plain words?

A linear rule is a straight line: change the input by a fixed amount and the output changes by a fixed amount too. A neuron in a network does a linear calculation. It multiplies each input by a weight, adds them up and adds a bias.

Non-linear means the output does not follow a straight line. It can flatten, bend, or switch on past a threshold. The step that adds this is an activation function, applied to each neuron's result before it goes to the next layer.

Think of a credit analyst adding points on a scoring form. Adding points at every stage is still just adding, so the whole form is one big sum. A rule that drops every negative score changes the shape of the total, and later stages can react to that new shape. In a network, the activation function plays the part of that rule.

Key words

Linear calculation
Multiply each input by a weight, add them up, add a bias. A straight-line rule.
Weight
A number the training adjusts to set how much each input counts.
Bias
A number added after the sum, which shifts the result.
Activation function
The non-linear step applied to each neuron's sum before the next layer.
ReLU
Keeps positive values and turns negative values into 0. Short for rectified linear unit.

Why does stacking linear layers not help?

Take two linear layers. The first turns the input into a number, and the second turns that number into an output. Put the two formulas together and you get one linear formula with the same reach. So a network with no bends is no stronger than a single layer, however many layers you add.

Two paths: with and without a bend

No bend between layers

Linear layer 1

a weighted sum of the input

Linear layer 2

a weighted sum of layer 1

Bend between layers

Linear layer 1

a weighted sum of the input

ReLU bend

negative values become 0

Linear layer 2

a weighted sum of the bent values

One linear formula

same reach as a single layer

Curves and thresholds

can fit real patterns

  1. 1The first layer's result feeds straight into the second.
  2. 2Both layers together come out as one linear formula.
  3. 3The first layer's result goes into the bend.
  4. 4The bend passes the result on to the second layer.
  5. 5Because of the bend, the output can flatten and then rise.
Top path: two linear layers that give one linear formula out. Bottom path: a bend between the layers, so the output can flatten and then rise. Only the bottom path can fit a real threshold.

Here is the same idea in code. The functions below give a made-up risk score for x, a claim size. Run it and read the table.

Python
# Made-up claims-risk score for one input x (say, a claim size). The numbers are invented.
def layer1(x):
    return x - 2              # linear: shift the input

def layer2(h):
    return 3 * h + 1          # linear: scale and shift again

def one_layer(x):
    return 3 * x - 5          # the two layers above, merged into one

def relu(v):
    return max(0, v)          # non-linear: negative signals become 0

print(f"{'x':>3} {'two_layers':>10} {'one_layer':>10} {'with_relu':>10}")
for x in [0, 1, 2, 3, 4]:
    two = layer2(layer1(x))
    one = one_layer(x)
    bent = layer2(relu(layer1(x)))
    print(f"{x:>3} {two:>10} {one:>10} {bent:>10}")

Output

  x two_layers  one_layer  with_relu
  0         -5         -5          1
  1         -2         -2          1
  2          1          1          1
  3          4          4          4
  4          7          7          7

The two_layers and one_layer columns match on every row, so the second layer added nothing. The with_relu column stays flat at 1 for small inputs, then rises, which a linear formula cannot do.

What does the bend buy you in real work?

Real data is full of thresholds. In a card fraud model (made-up numbers), normal spending should barely move the risk score. The score should climb once a card is used more than three times in ten minutes. A linear rule averages that into one slope, so it misreads both the ordinary days and the burst. A bend lets the model stay flat, then rise at the threshold.

  • “Linear calculations performed on the output of linear calculations are also linear, which means this model cannot learn nonlinearities.”

    Google, machine learning course (nodes and hidden layers)

  • “Stacking nonlinearities on nonlinearities lets us model very complicated relationships between the inputs and the predicted outputs.”

    Google, machine learning course (activation functions)

  • Sigmoid

    Squashes to 0 to 1

    Gives a probability-like output, so it suits the end of a model. Its training signal fades in deep stacks.

  • Tanh

    Squashes to -1 to 1

    Its range is -1 to 1, so outputs can be negative. Like sigmoid, its training signal fades in deep stacks.

  • ReLU

    Zero or the input

    Cheap to compute, and its signal fades less in deep stacks. Google's course still recommends starting with it.

Tip

In an interview, say what the bend does to the shape the next layer sees. Skip the claim that the bend makes the model smarter on its own.

What does the interviewer want to hear?

A strong answer covers

  • Without a bend, stacked linear layers collapse into one linear formula.
  • An activation function such as ReLU adds the bend after each layer's sum.
  • The bend lets the network learn thresholds, curves and interactions.
  • The common choices: sigmoid, tanh and ReLU, and when each fits.
  • A real case, such as a fraud burst that a straight line misses.
  • Google's course recommends starting with ReLU; sigmoid suits a probability at the output.

Common traps

  • Trap"Adding more layers makes the network smarter by itself."

    BetterDepth only helps with a bend between layers. Without one, extra layers collapse into one.

  • Trap"Any activation works, so pick one at random."

    BetterSigmoid and tanh are more prone to fading in deep stacks. Google's course recommends starting with ReLU.

  • Trap"Non-linear means the model is complicated."

    BetterIt means the output does not follow a linear formula of the input. The bend is a small, cheap step.

Can you spot the problem?

Spot the collapse

A junior engineer builds a three-layer churn model. Which snippet would collapse into one linear formula, so the depth adds nothing?

Quick check

A fraud model's risk should stay flat for normal spending, then rise sharply after a burst. Which change makes that shape possible?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q415What is gradient descent?12 min
  2. Q417What does the learning rate do?11 min
  3. Q418What is backpropagation?11 min
  4. Q437Softmax vs sigmoid?12 min
  5. Q438Why does weight initialisation matter?12 min

Learn it in depth

Last updated on 27 November 2026

Building a model that has to follow a real threshold?

I design and build AI systems, from the model to the screens around it. Book a short call and tell me what your data and decisions look like.