Overview

9 Artificial neural networks

Artificial neural networks are presented as powerful learning systems inspired by biological neurons and positioned within the broader machine learning lifecycle. The chapter motivates when to use ANNs—especially for complex, unstructured, and nonlinear problems—and frames deep learning as families of neural architectures trained on data to map inputs to outputs. It builds intuition from biological signaling to the logical abstraction of neurons, then traces how networks fit into the iterative ML process of problem definition, data preparation, training, evaluation, and improvement.

The text moves from the Perceptron—its inputs, weights, bias, summation, and activation—and its limitation to linear separability, to multilayer networks that overcome this by stacking hidden layers. It explains forward propagation (weighted sums plus activation across layers) and training via backpropagation, where errors are compared to targets, gradients are computed with the chain rule, and weights are adjusted through (stochastic) gradient descent. Practical essentials include scaling inputs (min–max) to avoid numeric bias, choosing activation functions (sigmoid, tanh, ReLU) and understanding vanishing gradients, selecting cost functions and learning rates, adding bias terms, initializing weights to avoid exploding/vanishing signals, monitoring loss, and stopping to prevent overfitting.

Design guidance covers shaping inputs/outputs, selecting the number of layers and nodes, and thinking in tensors for efficient, vectorized computation. The chapter also recasts ANNs in linear algebra—dot products and matrix multiplications—offering a compact mathematical view of forward and backward passes. It concludes with a tour of specialized architectures and their use cases: RNNs for sequences and temporal context, CNNs for image feature extraction and classification, and GANs for generative modeling—while noting the rise of Transformers for language. Together, these foundations connect core ANN mechanics to modern applications such as large language models and generative image systems.

A map describing the flexibility of deep learning and ANNs
A workflow for machine learning experiments and projects
A simplified model of a biological neural system
The general composition of neurons
Logical architecture of the Perceptron
An example of using a trained Perceptron
The sigmoid function
Example of a linear classification problem
Example ANN architecture for the car-collision example
Min-max scaling example with car collision data
Example ANN architecture for the car-collision problem
Example of a hidden node comparing terrain quality and degree of vision
Example of a hidden node comparing terrain quality and total experience
Life cycle of forward propagation in an ANN
Example of weights in a pretrained ANN
Mathematical denotation of an ANN
Weighted sum calculation for each hidden node
Activation function calculation for each hidden node
Final activation calculation for the output node
Life cycle of training an ANN
Example initial weights for an ANN
Example of forward propagation with randomly initialized weights
Weight versus cost plotted
Derivatives’ slopes and direction of minimums
Example of adjusting a weight by using gradient descent
Formula for calculating weight updates with the Chain Rule
Weight-update calculation with the Chain Rule
Example of the final weight-update for the ANN
Commonly used activation functions
An example of a multilayer ANN with more than one output
Comparison of tensor data structures
Simple example of a RNN
Simple example of a CNN
Simple example of a GAN

Summary of artificial neural networks

FAQ

What is an artificial neural network (ANN) and how does it relate to deep learning?An ANN is a computational model inspired by biological neurons that learns from data by adjusting connection weights to map inputs to outputs. Deep learning refers to using ANNs—often with many layers and specialized architectures—to solve tasks in supervised, unsupervised, and reinforcement learning.
When should I use an ANN instead of a traditional machine learning model?Use ANNs when you have complex, high‑dimensional, or unstructured data (images, audio, text) and relationships that are hard to hand‑engineer. For many tabular or simpler problems, traditional ML (e.g., linear/logistic regression, trees) can be faster, easier, and competitive—so compare models within a proper ML lifecycle.
What is a Perceptron and how does it differ from a full ANN?The Perceptron is a single “neuron” that: - Takes inputs, multiplies by weights, sums them (plus optional bias), and applies an activation. - Solves only linearly separable problems. An ANN chains many such neurons in one or more hidden layers, enabling learning of nonlinear decision boundaries across multiple dimensions.
Why is feature scaling important, and how does min‑max scaling work?Without scaling, features with larger numeric ranges can dominate learning even if they’re not more informative. Min‑max scaling rescales each feature to [0, 1] via (value − min) / (max − min), letting the network weigh features by predictive power rather than raw magnitude.
What is forward propagation in an ANN?Forward propagation computes a prediction by: - Multiplying inputs by input→hidden weights and summing per hidden node. - Applying an activation function to each hidden node’s sum. - Multiplying hidden activations by hidden→output weights, summing, and activating to produce the final output (often a probability).
What is backpropagation, and how do gradient descent and the Chain Rule fit in?Backpropagation trains the network by: - Computing loss (difference between prediction and target). - Using the Chain Rule to find how each weight affected the loss (gradients). - Adjusting weights in the direction that reduces loss (gradient descent), typically over many epochs.
Which activation functions should I use, and why?Common choices: - Step unit: For hard 0/1 outputs (not for hidden layers). - Sigmoid/Tanh: Smooth probabilities; risk vanishing gradients at extremes. - ReLU: Fast, sparse activations; mitigates vanishing gradients and reduces computation. Hidden layers often use ReLU; output activations depend on the task (e.g., sigmoid for binary).
How do I design an ANN’s architecture and training setup?Key choices include: - Inputs/Outputs: Define interface (e.g., pixels → class probabilities). - Hidden layers/nodes: More depth/width for more complex functions; tune empirically. - Weights: Smart initialization (e.g., Xavier/Glorot) to avoid vanishing/exploding gradients. - Bias: Shifts activation thresholds for flexibility. - Cost function: Match to problem (e.g., MSE, cross‑entropy). - Learning rate/optimizer: Balance speed vs. stability; consider SGD variants.
How are ANNs expressed and computed efficiently with linear algebra and tensors?Neurons’ weighted sums are dot products; entire layers use matrix multiplications, followed by element‑wise activations. Frameworks represent inputs, weights, and activations as tensors (multi‑dimensional arrays) to run highly parallelized operations on GPUs/TPUs.
What ANN variants exist and what are their typical use cases?- CNNs: Convolutions + pooling for images (e.g., classification, detection, medical imaging). - RNNs (historical) and modern Transformer architectures: Sequences like text and speech (e.g., translation, generation). - GANs: Generator vs. discriminator for realistic data synthesis (e.g., images, deepfakes, 3D from 2D).

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Algorithms, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Algorithms, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Algorithms, Second Edition ebook for free