Neural Network Basics
Prerequisites
- ML Fundamentals — Supervised learning, loss functions, gradient concepts
🎯 Learning Objectives
- Understand the biological inspiration behind artificial neural networks
- Describe the McCulloch-Pitts neuron model and its limitations
- Explain weighted sums, thresholds, and bias terms
- Appreciate the Universal Approximation Theorem
- Define fundamental terminology: layers, nodes, weights, bias, connections
- Trace the historical evolution from early perceptrons to deep learning
1. Biological Neurons
The human brain contains roughly 86 billion neurons, each connected to about 7,000 other neurons through structures called synapses. Understanding biological neurons helps motivate the design of artificial neural networks.
Biological Neuron Components
- Dendrites: Branch-like structures that receive electrical signals from other neurons.
- Cell Body (Soma): Integrates (sums) the incoming signals. If the total exceeds a threshold, the neuron “fires.”
- Axon: A long fibre that transmits the output signal to other neurons.
- Synapse: The junction between the axon of one neuron and the dendrite of another. Each synapse has a strength (analogous to a weight).
A biological neuron operates in a simple, elegant way: it accumulates electrical potentials from many incoming synapses. When the accumulated potential exceeds the activation threshold, the neuron fires an electrical pulse (action potential) along its axon. This all-or-nothing behaviour inspired early computational models.
2. McCulloch-Pitts Neuron Model (1943)
Warren McCulloch and Walter Pitts proposed the first mathematical model of a neuron in 1943. Their model is the foundation upon which all neural network research is built.
McCulloch-Pitts (MCP) Neuron
A binary unit that receives binary inputs x1, x2, …, xn ∈ {0, 1} and produces a binary output y ∈ {0, 1}:
y = 1 if ∑ x_i ≥ θ
y = 0 otherwise
where θ is a fixed threshold.
Example: AND Gate with MCP Neuron
Two inputs x1, x2. Set threshold θ = 2.
| x1 | x2 | ∑ | y (output) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 2 | 1 |
The MCP neuron with θ = 2 implements the AND function.
Example: OR Gate with MCP Neuron
Two inputs x1, x2. Set threshold θ = 1.
| x1 | x2 | ∑ | y (output) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 2 | 1 |
Limitations of the MCP model
- All inputs have equal weight — there is no mechanism to learn the relative importance of inputs.
- Inputs and outputs are binary only.
- The threshold θ is hand-set, not learned from data.
- Cannot implement XOR (exclusive-or) with a single MCP unit.
3. The Artificial Neuron
The modern artificial neuron generalises the MCP model by introducing learnable weights and a bias term, and allowing continuous-valued inputs.
Artificial Neuron (Formal Definition)
Given an input vector x = (x1, x2, …, xn), weight vector w = (w1, w2, …, wn), and bias b:
z = w1x1 + w2x2 + … + wnxn + b = w·x + b
y = f(z)
where f is an activation function (step, sigmoid, ReLU, etc.).
Key improvements over the MCP model:
- Weights: Each input has its own weight wi, allowing the model to learn the importance of each feature.
- Bias: The bias b shifts the decision boundary, replacing the fixed threshold.
- Continuous Activation: Smooth functions like sigmoid enable gradient-based learning.
Relationship: Threshold ↔ Bias
The MCP threshold θ can be converted to a bias: set b = −θ. Then the condition ∑wixi ≥ θ becomes ∑wixi + b ≥ 0. This is why the bias is sometimes called the negative threshold.
4. Network Terminology
Before diving deeper, let us establish the standard vocabulary used throughout this chapter.
Key Terms
| Term | Definition |
|---|---|
| Node / Unit / Neuron | A computational element that computes a weighted sum and applies an activation function. |
| Layer | A collection of neurons that operate in parallel at the same depth in the network. |
| Input Layer | The first layer; each node corresponds to one input feature. No computation occurs here. |
| Hidden Layer | Any layer between input and output. These layers learn internal representations. |
| Output Layer | The final layer; produces the network’s prediction (regression value, class probabilities, etc.). |
| Weight (w) | A learnable parameter on each connection, controlling signal strength. |
| Bias (b) | A learnable parameter added to the weighted sum, allowing shifts in the activation. |
| Activation Function | A (usually non-linear) function applied to the weighted sum: f(z). |
| Feedforward Network | A network where information flows strictly from input to output with no cycles. |
| Deep Network | A network with two or more hidden layers. |
GATE Tip: Counting Layers
When a question says “a 2-layer neural network,” it typically means 2 layers of learnable weights (i.e., 1 hidden layer + 1 output layer). The input layer is generally not counted because it performs no computation. Always check the context of the question.
5. Neural Networks as Universal Function Approximators
Universal Approximation Theorem (Cybenko, 1989; Hornik, 1991)
A feedforward neural network with a single hidden layer containing a finite number of neurons can approximate any continuous function on compact subsets of ℝn to any desired degree of accuracy, provided the activation function is non-constant, bounded, and continuous (e.g., sigmoid).
What it means: In theory, a single hidden layer is sufficient to represent any continuous mapping. However, the theorem says nothing about:
- How many neurons are needed (could be exponentially many).
- Whether gradient descent can find the right weights.
- How well the network generalises to unseen data.
Why We Still Use Deep Networks
Although a single hidden layer can approximate any function in theory, deeper networks can represent the same functions with exponentially fewer neurons. Depth provides a hierarchical composition of features that is both more efficient and more effective in practice.
6. Historical Timeline
Understanding the history of neural networks helps contextualise modern deep learning and is occasionally tested in GATE.
| Year | Milestone | Significance |
|---|---|---|
| 1943 | McCulloch & Pitts | First mathematical model of a neuron |
| 1958 | Rosenblatt’s Perceptron | First learning algorithm for a single-layer network |
| 1969 | Minsky & Papert’s Perceptrons | Proved XOR limitation; triggered the first “AI winter” for neural nets |
| 1986 | Backpropagation (Rumelhart, Hinton, Williams) | Efficient training of multi-layer networks |
| 1989 | Universal Approximation Theorem | Theoretical justification for neural networks |
| 1998 | LeNet-5 (Yann LeCun) | First successful CNN for digit recognition |
| 2006 | Deep Belief Networks (Hinton) | Revived interest in deep learning via unsupervised pre-training |
| 2012 | AlexNet (Krizhevsky) | Won ImageNet; ignited the modern deep learning era |
| 2014 | GANs (Goodfellow) | Generative Adversarial Networks introduced |
| 2017 | Transformer (Vaswani et al.) | “Attention Is All You Need” — foundation for GPT, BERT |
7. GATE-Style Worked Examples
Example 1: MCP Neuron for NOT
Problem: Design an MCP neuron that computes the NOT function (single input x, output ¬x).
Solution: We need an inhibitory input. In the standard MCP model, we can use a negative weight (extended MCP):
- Set w1 = −1, bias b = 0.5 (or equivalently threshold θ = −0.5 with unit weights).
- z = −1 · x + 0.5
- When x = 0: z = 0.5 > 0 ⇒ y = 1
- When x = 1: z = −0.5 < 0 ⇒ y = 0
This correctly implements NOT.
Example 2: Parameter Counting
Problem: A feedforward neural network has an input layer of 4 neurons, one hidden layer of 6 neurons, and an output layer of 3 neurons. All layers are fully connected. How many learnable parameters are there?
Solution:
- Step 1: Weights from input to hidden: 4 × 6 = 24
- Step 2: Biases in hidden layer: 6
- Step 3: Weights from hidden to output: 6 × 3 = 18
- Step 4: Biases in output layer: 3
- Total: 24 + 6 + 18 + 3 = 51 parameters
General Formula
For a fully-connected layer with nin inputs and nout outputs: Parameters = nin × nout + nout
Summary
- Artificial neural networks are inspired by biological neurons but use a mathematical abstraction: weighted sum + activation function.
- The McCulloch-Pitts model (1943) is the simplest neuron: binary I/O, fixed threshold, equal weights.
- Modern artificial neurons add learnable weights, bias, and non-linear activation functions.
- The Universal Approximation Theorem guarantees that a single hidden layer can approximate any continuous function — but deep networks are more efficient in practice.
- Key terminology: input/hidden/output layers, weights, bias, activation function, feedforward, deep network.
- For GATE: know parameter counting formula: nin × nout + nout per fully-connected layer.