liveBook · Manning

Activation function

As explained in Deep Learning with Python, Third Edition

A nonlinear function applied to a layer’s output to reshape it and increase model expressiveness.

An activation function reshapes a layer’s output so a model can learn useful nonlinear representations. Choose it according to the job of the layer and the allowed output range. section 4.1.3 section 4.3.3

Sentiment classification

A practical classifier uses two Dense layers with 16 units and relu activations, followed by one sigmoid unit. Each relu applies output = relu(dot(input, W) + b) and zeroes negative values. The sigmoid output becomes a score between 0 and 1, suitable for interpreting the review as probably positive or negative. section 4.1.3

Use these practical rules when selecting the final activation:

  • Use relu in intermediate Dense layers when the model needs flexible internal representations. section 4.1.3
  • Use sigmoid for a single output that should stay between 0 and 1. section 4.1.3
  • Use no activation for scalar regression when predictions must cover any numeric range; sigmoid would constrain them to 0–1. section 4.3.3

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains relu through tensor operations and output behavior, but defers formal principles for choosing layer architectures.
Examples
Uses a sentiment classifier with relu and sigmoid, plus scalar regression with a linear final layer.
What it assumes
Assumes familiarity with Dense layers and tensor operations while establishing relu, sigmoid, and linear output behavior.
What you can do after
Apply it via Keras by matching hidden-layer and output activations to the prediction task.
How it connects
Connects activation functions with Dense layers, representation space, classification, regression, and overfitting.

Also explained in

Compare how 14 books explain activation function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.