liveBook · Manning

Output layer

As explained in Grokking Machine Learning, Second Edition

An output layer is the final neural-network layer that produces the model's outputs.

An output layer is the final layer of a neural network. It converts the work of the hidden layers into the model’s predictions. section 10.8

Choose the output layer according to the prediction task:

  • For two-class classification, use two output nodes with a softmax activation and represent labels as two-column categorical vectors. section 10.18
  • For numerical regression, use one output node with no activation function, allowing the network to predict any numerical value. section 10.20
  • Treat the output size as the number of non-bias nodes in the final layer. section 10.8

Two tasks, two output designs

A circular dataset uses two hidden layers followed by Dense(2, activation='softmax'), producing class probabilities. A house-price model ends with Dense(1), producing a numerical prediction and training with mean squared error. section 10.18 section 10.20

Figure 10.21 The architecture that we will use to classify our dataset. It contains two hidden layers: one of 128 and one of 64 nodes. The activation function between them is a ReLU, and the final activation function is a softmax.

Use the architecture diagram to see how hidden layers feed into a final softmax output layer. section 10.18

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Specifies output size, activation choice, label representation, and compatible loss functions through working Keras architectures.
Examples
Uses a circular classification dataset and a Hyderabad house-price regression dataset as concrete output-layer examples.
What it assumes
Assumes input and hidden layers while defining their positions and roles from a basic fully connected architecture.
What you can do after
Build it from scratch by selecting output size, activation, labels, and loss for a Keras neural network.
How it connects
Connects input layers, hidden layers, activation functions, neural-network architecture, classification, regression, and loss functions.

Also explained in

Compare how 7 books explain output layer →

Related concepts

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