Sources: Artificial_Neural_Network.pdf; Section 2: Multilayer Perceptrons from L03 Multilayer Perceptrons.pdf; and the supplementary logic-gates perceptron article.
An artificial neural network (ANN) connects simple numerical units. Each unit computes a weighted sum, applies an activation function, and passes its result onward. A single perceptron draws one linear decision boundary; hidden layers let a multilayer perceptron (MLP) learn nonlinear functions such as XOR.
1. Why neural networks?
Biological brains process information through many interconnected neurons acting in parallel. ANNs are simplified mathematical models inspired by that idea - they do not reproduce the brain in full.
| Biological idea | ANN counterpart |
|---|---|
| Dendrites receive signals | Input features |
| Synapses strengthen or weaken signals | Weights |
| Neuron combines inputs and fires | Weighted sum + activation function |
| Neural pathways adapt through learning | Weights/biases are updated during training |
What this figure means: each input is multiplied by its own weight. The products are added, then a transfer/activation function turns that value into the unit output. A large positive weight supports activation; a negative weight inhibits it.
Early threshold models
The McCulloch-Pitts neuron is an early threshold model: fixed weighted inputs are summed and compared with a threshold to emit a binary output. It explains Boolean logic but does not learn its weights.
The perceptron is the learnable version of this basic model. It changes weights and bias from labelled mistakes, so it can learn a linear decision boundary from training examples.
Input values say what is present; weights say how important it is; bias sets how easily the neuron activates.
2. The artificial neuron
For inputs , weights , and bias :
where is the net input, is the activation function, and is the unit activation/output.
What this figure means: the arrows entering the neuron carry inputs; the labels are weights; computes the weighted sum; applies the activation function; the right-side arrow is the final output.
Important terms
| Term | Meaning |
|---|---|
| Weight | Learnable multiplier controlling an input’s influence. |
| Bias | Learnable constant that shifts the activation threshold. |
| Threshold | Boundary at which a step unit changes output; bias is an equivalent, convenient form. |
| Learning rate | Step size used while updating parameters during training. |
| Node/unit/neuron | One computational element. |
| Layer | A group of units evaluated at the same stage. |
| Input, hidden, output layers | Respectively receive features, learn intermediate representations, and produce the prediction. |
Compute the output of a sigmoid neuron for , and bias . The score is . Therefore .
3. Activation functions
Without a nonlinear activation function, several stacked linear layers still combine into one linear transformation. Nonlinearity is what gives neural networks their nonlinear modelling power.
| Function | Formula / behaviour | Main use or meaning |
|---|---|---|
| Step / hard threshold | if , otherwise | Classic perceptron and hand-designed logic gates. Not suitable for gradient descent because its derivative is zero almost everywhere. |
| Sigmoid | Smooth output in ; can approximate a hard threshold. | |
| Tanh | Smooth output in and zero-centred. | |
| ReLU | Common hidden-layer activation; simple and efficient. | |
| Softmax | Converts multiclass output scores into probabilities summing to 1. |
Hard versus soft thresholds
A hard threshold is convenient for showing logic gates, but its lack of useful derivatives prevents ordinary gradient-based training. A steep sigmoid or other differentiable activation is a soft threshold: it behaves similarly while remaining trainable with gradient descent.
For inputs , weights and bias , compute the output with sigmoid, tanh and ReLU. First calculate . Then , and . The same score enters each activation; do not apply the three activations sequentially.
4. Perceptron and the perceptron learning rule
A binary perceptron predicts
For a training example with target , the standard update is
- If the prediction is correct, , so no update is made.
- If a positive example is predicted as 0, its active-feature weights increase.
- If a negative example is predicted as 1, its active-feature weights decrease.
The perceptron learning rule converges only when the training classes are linearly separable: one straight line (or hyperplane in higher dimensions) can separate them.
What this figure means: the constant input supplies the bias. The two Boolean inputs enter one threshold unit. Correct weights make only cross the threshold, implementing AND.
5. Logic gates with perceptrons
Use
Many parameter choices work; the following are valid simple choices.
| Gate | Perceptron expression | Why it works |
|---|---|---|
| AND | Only . | |
| OR | Any input equal to 1 makes the sum positive. | |
| NOT | Input 0 produces 1; input 1 produces 0. | |
| NAND | It is 0 only when both inputs are 1. | |
| NOR | It is 1 only when both inputs are 0. |
Why XOR and XNOR need hidden layers
| XOR | XNOR | ||
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
The positive XOR points and lie diagonally opposite; one straight line cannot separate them from the negative points. So a single perceptron cannot represent XOR or XNOR.
XOR as a two-layer network
XNOR as a two-layer network
AND, OR, NOT, NAND, and NOR are linearly separable, so one perceptron can model each. XOR and XNOR are not linearly separable, so they require at least one hidden layer.
Realize NAND using a perceptron. For binary inputs and the rule when , choose and . The scores for 00, 01, 10 and 11 are 1.5, 0.5, 0.5 and , so outputs are 1, 1, 1 and 0. A single perceptron cannot realize XOR because XOR’s positive and negative inputs are not linearly separable; a multilayer network can combine intermediate gates.
6. ANN layers and architectures
What this figure means: a fully connected network links every node to every other node (often impractical). A layered network divides nodes into input, hidden, and output layers, restricting which units can communicate directly.
| Architecture | Meaning |
|---|---|
| Single-layer network | Has inputs connected directly to outputs; no hidden layer. It can only form linear decision boundaries. |
| Multilayer network | Has one or more hidden layers between input and output. Hidden units build intermediate features. |
| Feed-forward network | Connections move only from an earlier layer to a later layer; there are no cycles. |
| Recurrent/feedback network | Has feedback connections/cycles, so a state can influence later computation. |
| Fully connected layer | Every unit in one layer connects to every unit in the next layer. |
| Modular network | Multiple specialised subnetworks with sparse connections between them. |
Topology notation
3-4-4-4-1 means 3 input units, three hidden layers each with 4 units, and 1 output unit. The number of learnable parameters depends on both the layer widths and the connections between consecutive layers.
7. Multilayer perceptrons (MLPs)
An MLP is a feed-forward, layered neural network. In the usual fully connected form, every unit in one layer connects to every unit in the next layer.
What this figure means: the left drawing shows individual neurons and connections. The right drawing groups the same neurons into layer boxes. The first box is input, middle boxes are hidden layers, and the final box produces the output.
Layer roles
- Input layer: holds the input features; it does not learn a transformation itself.
- Hidden layers: learn representations that make the task easier. Their target values are not supplied directly.
- Output layer: produces the prediction: one unit for regression/binary classification, or typically one unit per class for multiclass classification.
- Depth: number of transformation layers; conventions differ on whether input/output layers are counted.
- Width: number of units in a layer.
For one hidden layer:
For multiple hidden layers, repeat the same pattern:
MLP computes XOR
What this figure means: the two hidden units each form a simple linear test. Together, their outputs let the final unit isolate the two XOR-positive corners. A hidden layer therefore combines several linear boundaries into a nonlinear decision region.
8. Feature learning and expressive power
An MLP does not need every useful feature to be designed manually. Hidden layers can learn nonlinear feature mappings from data.
What this figure means: the left side contains MNIST digit images. On the right, each small square visualises the weights entering one first-layer hidden unit. Light/dark patterns correspond to positive/negative weights. Many filters detect oriented edges or strokes; later layers combine these simple features into more complex digit patterns.
Why activation functions and depth matter
-
A deep network with only linear activations is still only one linear transformation:
It has no more expressive power than a single linear layer.
-
With nonlinear activations, a one-hidden-layer MLP can represent arbitrary functions under technical conditions (universal approximation).
-
Universality does not mean that a shallow network is practical: it may need exponentially many units and can simply memorise data.
-
Depth can represent some functions much more compactly than a shallow network. In practice, successive layers often transform low-level patterns into more task-relevant features.
9. Learning, deep networks, and common visual examples
Training adjusts weights and biases to reduce a loss between the predicted and target outputs.
| Learning type | Feedback | ANN example |
|---|---|---|
| Supervised | Correct labels are given. | Learn fruit labels from examples tagged apple/banana. |
| Unsupervised | No labels are given. | Group cat and dog images by visual similarity without knowing their names. |
| Reinforcement | Rewards/penalties follow actions. | Learn actions that maximise long-term reward. |
What this figure means: labelled fruit examples are given as training inputs. The network learns features such as colour and shape, then predicts the label of a new fruit. The known labels are the supervisor signal.
What this figure means: without labels, the system can still form groups of similar images. It discovers clusters; a person may later interpret one as “cats” and another as “dogs.” Clustering does not itself supply the names.
Deep learning
Deep learning uses neural networks with many hidden layers. Each layer transforms its input so later layers can use progressively more abstract/task-relevant features.
What this figure means: early layers respond to simple visual patterns; middle layers combine them into parts; deeper layers combine parts into an object/class prediction. It illustrates hierarchical feature learning, not a literal fixed sequence every model must follow.
What this figure means: a convolutional neural network (CNN) repeatedly applies convolution filters and max-pooling to images. Pooling reduces spatial size while retaining strong activations. The resulting feature maps are flattened and passed to fully connected layers for the final class, such as dog or cat.
10. Applications
ANNs and deep networks are used in pattern recognition, prediction, diagnosis, process modelling, customer targeting, credit and policy decisions, fraud/security detection, and engineering analysis.
Neuron: weighted sum + bias + activation.
Perceptron: one linear boundary; update weights from classification error.
MLP: feed-forward network with hidden layers and nonlinear activations.
XOR/XNOR: need hidden layers because they are not linearly separable.
Deep network: learns hierarchical representations; linear-only depth adds no nonlinear power.













