8  The Architecture of Learning

Neural Networks, Backpropagation, and the Rise of Deep Learning

CSC5350 · Artificial Intelligence


8.1 Opening Narrative

8.1.1 The Problem That Took Forty Years to Solve

In 1969, two eminent AI researchers at MIT published a book that nearly killed a field. Marvin Minsky and Seymour Papert’s Perceptrons proved, with mathematical rigor, that a single-layer neural network could not solve the XOR problem — a simple logical operation in which the output is 1 when the inputs differ and 0 when they are the same. Their critique was technically correct. It was interpreted as a verdict on neural networks broadly. Funding dried up. Researchers moved on.

What Minsky and Papert’s critique missed — or at least underemphasized — was that their proof applied only to single-layer networks. A network with even one hidden layer can solve XOR trivially. The limitation was architectural, not fundamental.

A small community kept working through the years that followed, convinced that the limitation was fixable. Geoffrey Hinton at the University of Toronto, Yann LeCun at Bell Labs, Yoshua Bengio at the Université de Montréal. Through two “AI Winters” when funding contracted and mainstream researchers moved elsewhere, this community refined the backpropagation algorithm, designed new architectures, and accumulated empirical evidence that deep networks could learn representations of extraordinary richness.

When AlexNet won the ImageNet challenge in 2012 by eleven percentage points — a margin so large that several committee members thought it must be a calculation error — the forty-year vindication was complete. The architecture that Minsky and Papert had critiqued as fundamentally limited had, with more layers, more data, and more compute, become the most powerful learning system ever built.

“The perceptron’s limitations were real. They were also temporary. The history of neural networks is a lesson in not confusing the limits of a first attempt with the limits of an idea.”


8.2 Learning Objectives

After completing this chapter, you will be able to:

  1. Describe the artificial neuron and explain how it computes a weighted sum followed by an activation function.
  2. Explain forward propagation through a multi-layer network and trace how activations flow from input to output.
  3. Derive the backpropagation algorithm using the chain rule and explain how it computes gradients with respect to all weights.
  4. Compare activation functions — sigmoid, tanh, ReLU, and variants — and explain why ReLU accelerated the training of deep networks.
  5. Describe how batch normalization, dropout, and residual connections address the challenges of training deep networks.
  6. Explain the architecture of convolutional neural networks and describe how convolution, pooling, and receptive fields give CNNs spatial intelligence.
  7. Describe recurrent neural networks and LSTMs and explain how they handle sequential data.
  8. Apply transfer learning using pre-trained models from PyTorch’s model zoo.
  9. Build the IAAIS Neural Perception Module — a deep feature extractor that provides rich representations for downstream modules.

8.3 Key Terminology

Term Plain-Language Definition
Artificial Neuron The basic computational unit of a neural network. Receives inputs, multiplies each by a weight, sums the results, adds a bias, and passes the result through an activation function.
Weight A numeric parameter controlling the strength of a connection between neurons. Training a neural network is the process of finding the right weights.
Bias An extra parameter in each neuron that shifts the activation function horizontally, allowing the neuron to be active even when all inputs are zero.
Activation Function A nonlinear function applied to the weighted sum of inputs. Without activation functions, a deep network would behave identically to a single layer.
ReLU Rectified Linear Unit: f(x) = max(0, x). Returns input if positive, zero otherwise. Computationally simple, avoids the vanishing gradient problem, enables rapid training of deep networks.
Sigmoid f(x) = 1/(1+e^{-x}). Squashes output to (0,1). Used in output layers for binary classification; avoided in hidden layers due to saturation and vanishing gradients.
Softmax Converts a vector of scores into a probability distribution over K classes. Used in output layers for multi-class classification.
Forward Propagation Computing a network’s output by passing input through each layer in sequence, from input to output. What happens at inference time.
Loss Function A measure of how wrong the network’s predictions are. Training minimizes the loss. Cross-entropy loss for classification; mean squared error for regression.
Backpropagation The algorithm for computing how much each weight contributed to the total loss, using the chain rule of calculus. Makes training of deep networks computationally tractable.
Gradient Descent Optimization strategy that updates weights in the direction of negative gradient of the loss — “downhill” in loss space.
Learning Rate Controls the size of each gradient descent step. Too large: oscillates, diverges. Too small: training is prohibitively slow. One of the most important hyperparameters.
Batch A subset of training examples processed together before updating weights. Full-batch gradient descent uses all examples; mini-batch (typical) uses 32-512.
Epoch One complete pass through the entire training dataset. Networks typically require many epochs — sometimes hundreds — to converge.
Overfitting The network memorizes the training data, achieving low training loss but high test loss. Prevented by regularization, dropout, and early stopping.
Dropout Regularization technique that randomly deactivates neurons during training. Forces the network to develop redundant representations and prevents co-adaptation.
Batch Normalization Normalizes layer activations during training, stabilizing and accelerating training of deep networks. Reduces sensitivity to weight initialization and learning rate.
Residual Connection A skip connection adding the input of a layer directly to its output: output = F(x) + x. Allows gradients to flow directly to earlier layers, enabling training of very deep networks (ResNet).
Convolutional Layer Applies learned filters to input images, detecting local spatial patterns regardless of where they appear. The key building block of CNNs.
Pooling Downsampling a feature map by aggregating values in local regions — max pooling keeps the maximum, average pooling keeps the mean. Reduces spatial dimensions and provides translation invariance.
Receptive Field The region of the input image that influences a particular neuron’s activation. Grows with network depth — deeper neurons “see” more of the input.
Recurrent Neural Network (RNN) A neural network with connections that loop back, allowing information from earlier time steps to influence later ones. Designed for sequential data.
LSTM Long Short-Term Memory. A sophisticated RNN variant with gating mechanisms that selectively remember and forget information over long sequences. Addresses the vanishing gradient problem in plain RNNs.
Transfer Learning Using a model pre-trained on a large dataset as a starting point for a new, related task. Lower layers capture general features; upper layers are fine-tuned for the specific domain.

8.4 Section 1 — From Perceptron to Deep Network

The perceptron, introduced by Frank Rosenblatt in 1958, was the first trainable single neuron. It computed a weighted sum of inputs and threshold-activated the result — predicting 1 if the sum exceeded the threshold, 0 otherwise. Weights were updated by a simple rule: if the prediction was wrong, move the weights in the direction that would have made it right.

The perceptron was genuinely revolutionary — a machine that could learn from labeled examples. But Minsky and Papert’s 1969 proof of its inability to solve non-linearly separable problems like XOR was accurate. The fix was conceptually simple: add one or more hidden layers between the input and output. A network with even one hidden layer of sufficient size can approximate any continuous function — the universal approximation theorem. The challenge was training it.

Training a multi-layer network requires computing how much each weight in every layer contributed to the output error. For the output layer, this is straightforward — the error is directly measurable. For hidden layers, it is not obvious: hidden neurons do not have direct labels, only the final output does.

Backpropagation solves this by applying the chain rule of calculus: the gradient of the loss with respect to any weight equals the product of gradients along the path from that weight to the loss. Backpropagation propagates the error signal backward through the network layer by layer, computing each weight’s contribution to the total error. This makes the gradient computation tractable even for networks with millions of weights.

# A single forward pass and the loss computation:

Input:  x = [age=65, wbc=18.4, temperature=38.9, creatinine=1.2]
                ↓
Hidden Layer 1: 64 neurons
  z₁ = W₁·x + b₁         # Weighted sum
  a₁ = ReLU(z₁)           # Activation: max(0, z)
                ↓
Hidden Layer 2: 32 neurons
  z₂ = W₂·a₁ + b₂
  a₂ = ReLU(z₂)
                ↓
Output Layer: 1 neuron
  z_out = W_out·a₂ + b_out
  ŷ = Sigmoid(z_out) = 0.73   # Predicted probability of sepsis

True label: y = 1.0  (patient has sepsis)
Loss = -[y·log(ŷ) + (1-y)·log(1-ŷ)]
     = -[1.0·log(0.73) + 0·log(0.27)]
     = -log(0.73) = 0.315

# Backpropagation computes ∂Loss/∂W for every weight W
# Gradient descent updates: W ← W - α × ∂Loss/∂W

8.5 Section 2 — Activation Functions and Training Stability

The choice of activation function matters more than it might appear. The wrong choice can make deep networks fail to train at all.

Sigmoid squashes values to (0, 1). It was the standard activation in early neural networks. Its critical flaw: the gradient of sigmoid is at most 0.25, and for large positive or negative inputs, it is nearly zero. When backpropagation multiplies these small gradients across many layers, the gradient signal reaching early layers is negligibly small — the vanishing gradient problem. Deep sigmoid networks cannot learn effectively because the gradient fails to reach the lower layers.

ReLU (Rectified Linear Unit) — f(x) = max(0, x) — solved the vanishing gradient problem almost entirely. Its gradient is 1 for positive inputs and 0 for negative inputs. Multiplying 1s through many layers keeps the gradient signal intact, enabling training of networks with dozens or hundreds of layers. ReLU also trains faster than sigmoid (simpler computation) and produces sparse activations (many neurons output exactly zero), which tends to improve generalization.

Batch Normalization, introduced in 2015, further stabilized deep training. By normalizing activations to have zero mean and unit variance after each layer (using statistics from the current mini-batch), batch norm dramatically reduces the sensitivity to weight initialization and allows the use of larger learning rates. Deep networks that previously required weeks to train could be trained in hours.


8.6 Section 3 — Convolutional Neural Networks: Spatial Intelligence

CNNs are the architecture that made deep learning’s ImageNet breakthrough possible. They encode three structural assumptions that are well-matched to image data:

Local connectivity: A neuron in a convolutional layer is connected only to a local region (receptive field) of the previous layer — not to the entire image. An edge detector does not need to see the whole image to detect an edge at one location.

Weight sharing: The same filter (set of weights) is applied at every position in the image. This reduces the number of parameters dramatically and forces the network to learn features that are useful everywhere — not just at specific locations.

Hierarchical composition: Early layers detect local features (edges, textures); later layers combine these into more complex features (shapes, object parts, whole objects). This hierarchy mirrors the structure of biological visual cortex.

A convolutional layer applies a set of learned filters to the input. Each filter produces a feature map — a 2D array showing where in the image that filter’s pattern was detected. Typical early-layer filters detect edges at different orientations; later-layer filters detect eyes, wheels, faces, or other meaningful object components.

Max pooling reduces spatial dimensions by keeping only the maximum activation in each local region. This achieves two things: it reduces computation (fewer numbers to process downstream) and introduces translation invariance — a shifted version of the same feature activates the same pooled output, making the network robust to small shifts in object position.

The progression of increasing filter counts and decreasing spatial dimensions that characterizes CNN architectures (e.g., 3×224×224 → 64×112×112 → 128×56×56 → …) reflects the conceptual progression from low-level local features to high-level global ones, with fewer but richer spatial positions at each stage.


8.7 Section 4 — Residual Networks: Enabling Extreme Depth

A counterintuitive phenomenon appeared as researchers stacked more layers: networks with 50 layers sometimes performed worse than networks with 20 layers, even on training data. This was not overfitting — both training and test performance degraded. The problem was optimization: very deep networks become hard to train because gradients must flow through many layers, and small errors or instabilities accumulate.

Residual connections (He et al., 2015) solved this with a conceptually simple modification. Instead of requiring each block to learn the desired output H(x), the block is asked to learn the residual F(x) = H(x) - x, with the block’s output being F(x) + x (where x is added back via a skip connection). If the optimal transformation is the identity (no change), F(x) should be driven to zero — which is much easier than learning the identity mapping through many nonlinear transformations.

More practically: the skip connection provides a direct path for gradients to flow backward from the output to any earlier layer, bypassing the nonlinear transformations in between. This “gradient highway” prevents the gradient from vanishing in very deep networks.

The result: ResNet-152 (152 layers) achieved 4.5% top-5 error on ImageNet — better than the previous best 20-layer networks — and training was actually more stable than shallower architectures. The scaling insights embodied in ResNet enabled the progression from dozens of layers to hundreds, and then to thousands, that characterizes modern architectures.


8.8 Section 5 — Recurrent Neural Networks: Learning From Sequences

CNNs process fixed-size inputs with spatial structure. Sequences — text, speech, time series, clinical vital sign streams — require a different architecture: one that can handle variable-length inputs and model dependencies between elements.

Recurrent Neural Networks (RNNs) maintain a hidden state that is updated at each time step, allowing information from earlier steps to influence later ones. The hidden state is the network’s “memory” of the sequence processed so far.

The training challenge: when backpropagation is applied through time (unrolling the RNN into a deep network), the vanishing gradient problem reappears — gradients must be propagated backward through potentially hundreds of time steps, and the multiplicative nature of the propagation causes them to shrink exponentially.

Long Short-Term Memory (LSTM) networks, introduced by Hochreiter and Schmidhuber in 1997, address this through a gating mechanism. Three gates — input, forget, and output — selectively control what information is written to, retained in, and read from the cell state. The critical innovation: the cell state pathway has a direct connection across time steps that allows gradients to flow backward without passing through nonlinear transformations. LSTMs can learn dependencies across hundreds of time steps — the regime where plain RNNs consistently fail.

Gated Recurrent Units (GRUs) simplify the LSTM gating mechanism while retaining most of its performance. For many applications, GRUs provide slightly better training efficiency without sacrificing capability.


8.9 Section 6 — Transfer Learning: Standing on Trained Shoulders

Training a state-of-the-art CNN from scratch requires millions of labeled images and days of GPU computation. For most real-world applications, this is neither necessary nor practical. Transfer learning provides an alternative: start from a model already trained on a large general-purpose dataset and adapt it to the target task.

The key insight: the lower layers of a CNN trained on ImageNet learn general visual features — edges, textures, shapes, patterns — that are useful far beyond the original classification task. A model trained to distinguish 1,000 ImageNet classes has learned representations that are valuable for detecting tumors in medical images, classifying plant diseases from leaf photographs, and identifying defects in manufactured components.

Transfer learning typically proceeds in two phases:

Feature extraction: Freeze all the pre-trained model’s layers. Add a new classification head. Train only the new head on the target dataset. This is fast, requires minimal data, and works well when the source and target domains are similar.

Fine-tuning: After training the head, unfreeze some or all of the pre-trained layers. Continue training with a very small learning rate. This allows the pre-trained representations to adapt to the specific characteristics of the target domain while avoiding catastrophic forgetting of the general features that make the representations valuable.

The practical guideline: use small target datasets (hundreds to low thousands) → feature extraction only. Moderate datasets (thousands to tens of thousands) → fine-tune the last few layers. Large datasets (tens of thousands or more) → fine-tune the full network. With very large target datasets, training from scratch becomes viable.


8.10 Section 7 — IAAIS Integration: The Neural Perception Module

This week you add the IAAIS Neural Perception Module — a deep feature extractor that transforms raw, unstructured inputs (images, time series, raw text features) into rich vector representations for downstream modules.

The Neural Perception Module’s outputs feed directly into the Classifier (Chapter 6): instead of hand-engineered features, the Classifier now works from learned deep representations. They also feed into the Uncertainty Module (probabilistic interpretation of network outputs) and the Knowledge Base (storing perception results as queryable facts).

For image inputs, use a pre-trained ResNet or EfficientNet backbone with transfer learning. For time series inputs, use a 1D CNN or LSTM encoder. For multimodal inputs, use separate encoders for each modality and concatenate or cross-attend the representations.

Chapter Module Capability
Ch 2 Search Engine Path planning
Ch 3 Knowledge Base Structured facts and inference
Ch 4 Planner Goal-directed action sequences
Ch 5 Uncertainty Module Calibrated probabilistic beliefs
Ch 6 Classifier Supervised prediction
Ch 7 Pattern Recognizer Unsupervised structure discovery
Ch 8 Neural Perception Module Deep feature extraction

8.11 Hands-On Exploration: Training and Visualizing a Deep Network

8.11.1 The Activity

Open hands_on_ch8.ipynb from the course repository.

Part 1 — Backpropagation from Scratch (20 minutes): Implement a two-layer network with manual forward propagation and backpropagation on the XOR problem (the same problem Minsky and Papert said a single-layer network couldn’t solve). Observe how the network’s predictions evolve across training epochs. Plot the decision boundary before and after training.

Part 2 — CNN on Image Data (20 minutes): Train a small CNN on the provided 8-class medical image dataset using PyTorch. Compare three configurations: (a) 2 convolutional layers, (b) 4 convolutional layers, (c) 4 convolutional layers with residual connections. Record training and validation accuracy curves. Which configuration trains fastest? Which achieves the highest final accuracy?

Part 3 — Transfer Learning (15 minutes): Load a pre-trained ResNet-18 from PyTorch’s model zoo. Replace the final classification head with one appropriate for your 8 classes. Fine-tune with two strategies: (a) head-only training for 10 epochs, then (b) full fine-tuning for 10 more epochs. Compare training curves and final accuracy to your from-scratch model.

8.11.2 Reflection Questions

  1. Your from-scratch CNN takes 30 minutes to reach 72% accuracy. Your transfer learning approach reaches 85% in 5 minutes. What exactly does the pre-trained model already know that makes this possible?
  2. Visualize the weights of your first convolutional layer (they can be displayed as images). What patterns did the network learn to detect? Do they look like what you expected?
  3. Dropout regularization helps, but it introduces randomness — different neurons are dropped each forward pass. How do you get consistent predictions at inference time?
  4. Your LSTM for sequence classification takes 50 time steps as input. What happens to the gradient by the time it reaches time step 1? How do the LSTM’s gates help compared to a plain RNN?

8.12 Case Study: AlexNet — The Moment Deep Learning Became Undeniable

8.12.1 The Competition

The ImageNet Large Scale Visual Recognition Challenge (ILSVRC) ran annually from 2010, asking teams to classify 1.2 million photographs into 1,000 categories. For two years, the best entries used hand-engineered features (HOG, SIFT) combined with classical classifiers, achieving top-5 error rates around 26%. Progress was incremental, measured in fractions of a percentage point per year.

8.12.2 The Breakthrough

In September 2012, a team of three from the University of Toronto — Alex Krizhevsky, Ilya Sutskever, and Geoffrey Hinton — submitted AlexNet. Its top-5 error rate was 15.3%. The previous year’s winner had achieved 26.2%. The margin was so large that initial reactions included suspicion of a computational error. No error was found.

AlexNet won not because of a single clever trick but because of a convergence of several factors. ReLU activations trained faster and deeper than sigmoid. Dropout prevented overfitting on a network with 60 million parameters. Data augmentation artificially expanded the training set through cropping, flipping, and color jitter. And critically: two NVIDIA GTX 580 gaming GPUs provided the computational throughput to train this architecture in a week rather than a year.

8.12.3 The Architecture

AlexNet was simple by modern standards: five convolutional layers followed by three fully connected layers. The first layer used large 11×11 filters; subsequent layers used progressively smaller filters on progressively richer feature maps. By the final convolutional layer, the network had learned representations encoding high-level visual concepts — not through explicit programming, but through hierarchical feature learning from the training data.

What the first layer learned was interpretable: its 96 filters detected edges and color blobs at various orientations — the same low-level features that human visual cortex responds to. What the later layers learned was far less interpretable, encoding complex combinations of features that no human designer would have thought to specify.

8.12.4 The Legacy

AlexNet’s margin established a principle that has proven robust across a decade of subsequent work: with the right architecture, sufficient data, and sufficient compute, deep learning would outperform every other approach on problems involving rich, unstructured perceptual data — and would continue to improve as any of those three ingredients increased. This scaling law — first revealed by AlexNet’s ImageNet results — drove the investment in data collection, compute infrastructure, and research talent that produced every subsequent development described in this textbook.


8.13 Chapter Summary

We began this chapter with Minsky and Papert’s 1969 proof that temporarily halted neural network research — and with the forty-year vindication that proved the limitation was architectural, not fundamental.

The artificial neuron gave us the basic unit: weighted sum, bias, activation function. Multi-layer networks built from this unit can approximate any function; backpropagation gave us the algorithm to train them. Activation functions — particularly the transition from sigmoid to ReLU — made training deep networks practically feasible by eliminating the vanishing gradient problem.

Batch normalization stabilized training across many layers. Residual connections enabled networks of hundreds of layers by providing gradient highways that bypass nonlinear transformations. These architectural innovations are why modern networks can be as deep as needed rather than as deep as is trainable.

CNNs gave us the specialized architecture for spatial data: local connectivity, weight sharing, and hierarchical composition mirror the structure of visual cortex and enable extraordinary performance on image recognition. RNNs and LSTMs gave us the architecture for sequential data: recurrent connections and gating mechanisms enable learning from sequences of arbitrary length.

Transfer learning made all of this accessible: instead of training from scratch on millions of examples, practitioners can start from pre-trained representations and fine-tune for specific tasks with modest data.

In Chapter 9, we turn to the application of these ideas to language — the transformer architecture, attention mechanisms, and the systems that can read and reason about text.


8.14 Discussion Questions

  1. Minsky and Papert: Their 1969 critique of the perceptron was technically correct. Yet the research community interpreted it as a verdict against multi-layer networks. How did this interpretive error cause a decade of delayed progress? What lessons does this history carry for how we interpret current AI limitations?
  2. Gradient descent as optimization: A neural network’s loss surface has many local minima. Why does gradient descent often find good solutions despite this? And what properties of a problem would cause it to reliably get stuck in bad local minima?
  3. CNNs and biological vision: CNNs were partially inspired by Hubel and Wiesel’s 1959 discovery of simple and complex cells in visual cortex. Yet modern CNNs make predictions in ways that are adversarially foolable — presenting invisible-to-humans perturbations that cause complete misclassification. What does this tell us about the similarity between CNN and biological vision?
  4. Transfer learning and domain shift: A pre-trained ImageNet model is used for detecting defects in medical images. ImageNet contains cats, cars, and furniture — not pathology. Why does transfer learning still work? At what point would the domain gap be too large for it to help?
  5. Dropout and uncertainty: Dropout at training time regularizes. At inference time, keeping dropout active and sampling many outputs produces a distribution over predictions — an approximation of Bayesian uncertainty. Describe how you would use this technique to produce calibrated confidence estimates from your neural network.
  6. Residual connections and very deep networks: ResNets with 1,000+ layers have been trained. At what point does depth stop helping, and why? What is the practical maximum useful depth for a typical task?
  7. RNNs vs. transformers: LSTMs model sequences recurrently; transformers use attention to relate any two positions directly. LSTMs process tokens sequentially (inherently serial); transformers process all positions in parallel. What implications does this have for computational efficiency and for the ability to model long-range dependencies?
  8. Your IAAIS Neural Perception Module: Choose an input modality relevant to your IAAIS domain (images, time series, raw sensor data, or another). Describe the architecture you would use, whether you would employ transfer learning (and from what source), and how the module’s output would connect to at least two other IAAIS modules.

8.15 Further Reading

8.15.1 Foundational Papers

Rumelhart, D. E., Hinton, G. E., & Williams, R. J. (1986). Learning representations by back-propagating errors. Nature, 323, 533–536. The paper that popularized backpropagation for multi-layer networks.

LeCun, Y., et al. (1998). Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11), 2278–2324. LeNet — the first successful deep CNN for practical application.

Krizhevsky, A., Sutskever, I., & Hinton, G. E. (2012). ImageNet classification with deep convolutional neural networks. Advances in NeurIPS. AlexNet — the paper that started the modern deep learning era.

He, K., et al. (2016). Deep residual learning for image recognition. CVPR 2016. ResNet — residual connections enabling very deep networks.

8.15.2 Recurrent Networks

Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural Computation, 9(8), 1735–1780. The LSTM paper.

8.15.3 Review Articles

LeCun, Y., Bengio, Y., & Hinton, G. (2015). Deep learning. Nature, 521(7553), 436–444. The landmark review by three of the field’s founders.

Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press. Available free at deeplearningbook.org. The comprehensive textbook.


— End of Chapter 8 —