Inside a neural network / 2 of 7

Activation functions

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Activation functions” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

Activation functions introduce nonlinearity so a network can model more than affine transformations. Their output ranges and gradients influence how information and learning signals flow through the network.

Treat a neural network as a computation graph, not a mysterious black box. Follow a tiny input through each operation and keep track of tensor shapes. Distinguish the forward pass, gradient computation, and optimizer update. These three stages are connected but solve different parts of the learning problem.

Under the hood

ReLU outputs max(0,x). Sigmoid maps to (0,1) but saturates at large magnitudes. Softmax normalizes a vector of logits into class probabilities, with outputs summing to one.

ReLU⁡(x)=max⁡(0,x)\operatorname{ReLU}(x)=\max(0,x)
ReLU returns 0 for negative inputs and returns the input value for positive inputs. At zero the output is also 0.
A useful caution

A softmax probability is not automatically calibrated confidence.

A worked example

ReLU applied to [−2,0,3] yields [0,0,3]. It is inexpensive but units with persistently negative inputs can stop receiving useful gradients.

How to use this way of thinking

Build intuition with a small calculation before scaling dimensions. Check whether the architecture can represent the desired relationship, then whether optimization can learn it, then whether the learned solution generalizes. A failure in any one of these stages needs a different response.

Try it yourself

Compare sigmoid outputs at 0 and at a very large positive input.

Key takeaways

  • To represent nonlinear relationships
  • A softmax probability is not automatically calibrated confidence.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1Why use nonlinear activations between dense layers?
2True or false: Sigmoid gradients remain large at extremely positive inputs.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Dive into Deep Learning (opens a new tab)PyTorch: automatic differentiation (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close