Perceptron & linear separability
This lecture builds the perceptron from the biological neuron (MP neuron, Rosenblatt perceptron, step activation). It shows the decision boundary and linear separability with OR, AND and XOR. After this page you can run PLA updates on OR and solve thresholds for AND and OR.
Biological neuron to artificial neuronSearch on YouTube
A biological neuron receives signals through dendrites. It processes them in the cell body. It fires through the axon when the net input passes a threshold. The hand-pulled-from-heat reflex shows this chain. Receptors sense heat, interneurons decide, motor neurons carry the response.
The artificial neuron copies this chain with numbers:
| Artificial component | Biological part | Function |
|---|---|---|
| Inputs | Dendrites | Receive signals |
| Weights | Synaptic strength | Set signal importance |
| Sum | Cell body (soma) | Combine inputs |
| Activation function | Firing mechanism | Decide output |
| Output | Axon | Pass output onward |
D-S-C-F-A
Dendrites take inputs · Synapses set weights · Cell body sums · Firing is activation · Axon sends output.
Computational unitsSearch on YouTube
A computational unit is the basic building block of a neural network. It receives scalar inputs. It multiplies each input by a weight. It sums the products. It passes the sum through an activation function such as thresholding. It emits one output value.
Think of a voting panel. Each member casts a weighted vote. The chair adds the votes. The motion passes when the total crosses a fixed mark.
McCulloch-Pitts neuronSearch on YouTube
McCulloch and Pitts published the MP neuron in 1943. It was one of the first formal neuron models. It performs binary logic with Boolean inputs. It has no learning. Its output follows a fixed threshold.
are fixed weights. are Boolean inputs ( or ). The neuron fires when the sum reaches the threshold.
Threshold logicSearch on YouTube
Threshold logic computes a function from a weighted sum. The neuron fires when the sum reaches a manually chosen threshold. No training adjusts the threshold. The designer picks it from the target logic.
Worked example: AND with an MP neuron. Set both weights to . Set the threshold to . The neuron fires only when both inputs are .
| Sum | Output | ||
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 2 | 1 |
Check each row.
The table matches AND. The threshold forces both inputs to be active.
is the output. The value is the fixed threshold for AND with unit weights.
MP neuron featuresSearch on YouTube
| Feature | Description |
|---|---|
| Inputs | Boolean ( or ) |
| Weights | Fixed, typically positive integers |
| Sum | Adds the weighted inputs |
| Threshold | Fixed integer value |
| Activation function | Step: when sum threshold, else |
| Output | Boolean ( or ) |
| Learning | None (no weight updates) |
Say "fixed threshold" for MP neurons in the exam. Say "learned weights and bias" for perceptrons. The contrast earns marks.
Supervised learningSearch on YouTube
Supervised learning learns a mapping from inputs to outputs. The input vector is . The learning algorithm searches for a function . The model must fit the training data. It must also predict new records correctly.
is the attribute vector. is the learned function. is the predicted output.
The slides show an table (for example , ). Each row pairs one input with its label. Learning means finding the behind such pairs.
Classification and regressionSearch on YouTube
Prediction learns a target function from each attribute set to an output . Classification predicts a categorical (spam or safe). Regression predicts a continuous (a number). The perceptron below does binary classification.
is the true label. is the predicted output. The loss measures how wrong one prediction is.
Linear perceptronSearch on YouTube
Rosenblatt proposed the perceptron in 1958. It is a single-neuron network. It was the first neuron model that could learn weights from data. It takes several inputs (real or Boolean). It applies weights and a bias. It passes the result through an activation function (typically a step). It handles only linear boundaries (a straight line or hyperplane).
The neuron output reports the activation level of that neuron. The slides call the activation function an "activity function" once. The canonical term is activation function.
Step and sigmoid activationSearch on YouTube
The activation function decides the activity level of a neuron.
Step functionSearch on YouTube
The step uses a threshold (the bias form appears below). The neuron stays dormant below . It becomes active at and above .
SigmoidSearch on YouTube
The sigmoid gives graded activity between and . The same input sum can thus give many activity levels. The slides use four sample points.
is the weighted sum plus bias. is the sigmoid. Large pushes toward . Small pushes toward .
Worked example: sigmoid activity levels. Apply to the four slide inputs.
Read the trend. Activity rises with . The neuron is nearly dormant at . It is strongly active at .
Patterns in solution spaceSearch on YouTube
Three step neurons give only dormant or active states. The total codebook is patterns. Sigmoid neurons give graded levels from to . With distinct levels each, three neurons give patterns. More states mean a larger solution space.
From threshold to biasSearch on YouTube
The perceptron fires when the weighted sum reaches the threshold. Subtract the threshold from both sides. The test becomes "shifted sum ". Write the negative threshold as (the bias). Then equals minus the threshold. Say "threshold" once as the alias. Use bias after that.
is the threshold. This is the threshold form of the step rule.
is the bias. is the net input. The perceptron fires when .
Do not mix the two signs. Threshold form tests . Bias form tests with . A flipped sign moves the boundary to the wrong side.
Training: loss and weight updatesSearch on YouTube
Three items control the output: weights, bias and activation. Training adjusts the weights and bias from feedback. The loss reports each mistake. Backpropagation pushes that feedback into weight and bias updates. Biology does the same: synapses strengthen or weaken with experience.
Linear separabilitySearch on YouTube
Linear separability splits the input space with one boundary. Points with positive response lie on one side. Points with negative response lie on the other. The boundary is also called the decision line.
The net input defines the sides:
means a positive response. means a negative response. The boundary is .
All three forms state the same boundary. The first uses the bias. The others use the threshold .
Line, plane or hyperplaneSearch on YouTube
The input count sets the shape. Two inputs give a line. Three inputs give a plane. More inputs give a hyperplane.
The left form is the two-input boundary. The right form recalls the school line .
OR with a perceptronSearch on YouTube
OR outputs only for . It outputs for , and . Write for the bias term. Then each row gives one inequality:
is the bias. are the input weights. Any triple that satisfies all four rows implements OR.
Worked example: solve the OR inequalities. Pick , , .
Read the boundary. The line is . It cuts the axes at and . The triple from the slides passes the same four tests.
Random weights and the error surfaceSearch on YouTube
Fix the bias and vary . Each trial draws one decision line. The slides try several lines. One line makes errors. A better line makes error. The error surface bottoms out when both and exceed . Random search wastes trials there. A principled rule finds the weights directly.
Push a fence until each animal stands on the right side. Each mistake tells you which way to push. PLA turns each mistake into one push.
Perceptron learning algorithmSearch on YouTube
The Perceptron Learning Algorithm (PLA) trains one perceptron for binary classification. is the positive class. is the negative class. is the weight vector (bias included). is the input vector (with ). PLA seeks the decision line that separates from . It stops when every input is classified correctly.
Predict when . Predict when . Update only on mistakes:
Add the input when the perceptron misses a positive point. Subtract the input on a false alarm. Leave unchanged on correct predictions.
Memorise the directions: miss means add, false alarm means subtract. The bias updates too because rides along.
PLA for OR, step by stepSearch on YouTube
Start from . Cycle the OR rows in order , , , . The slides show the first four computations. The trace below continues to convergence at .
Steps 1 to 4: first pass. Current weights are .
Steps 5 to 8: second pass. Current weights are .
Step 9: verify convergence. Test all rows with .
All four rows match OR. PLA stops. The slide target is another valid separator.
Convergence theoremSearch on YouTube
The theorem answers one question: does PLA stop after finite steps? It stops when the two classes are linearly separable. It needs finite point sets. It tests the vectors cyclically, one after another.
Two sets and in -dimensional space are absolutely linearly separable when weights exist with:
sits fully on the positive side. sits fully on the negative side. The same serves both lines.
Proposition: when and are finite and linearly separable, PLA updates the weight vector finitely many times. After finite steps , the vector separates the two sets.
Run PLA only on separable data. On overlapping classes it never settles. It cycles through mistakes without end.
Spam filter and XOR limitSearch on YouTube
Real tasks often reduce to linear choices. The spam scenario uses two binary features. Feature when "free" appears. Feature when "win" appears. The slides label as safe. They label , and as spam. That table is OR. One perceptron implements it.
XOR breaks the perceptron. XOR outputs for and . It outputs for and . Opposite corners share labels. No single straight line isolates the two s.
Worked example: prove XOR needs more than one line. Assume a separator exists with for .
Derive the clash. Add the two middle rows.
So . This clashes with . No triple satisfies all rows. XOR is nonlinear for one perceptron. Higher networks (with hidden layers) handle it.
Try PLA on OR and XOR below. Move the weights or press Play PLA and watch the line react.
Line is w1x1+w2x2+w0=0. Blue dots output 1. Hollow dots output 0.
z = 1x1 + 1x2 + -1. Predict 1 when z ≥ 0.
Weights solve OR. Press Reset, then Play PLA. 4 of 4 rows pass. Mistakes: 0.
ANN layersSearch on YouTube
The network stacks neurons in layers. The arrangement plus the connection pattern is the network architecture.
- Neuron: a cell that sums weighted inputs, adds a bias and holds activity .
- Input layer: the first layer. It receives the raw input vector. With dimensions, it holds neurons. Each neuron is a placeholder for one dimension (no computation).
- First dense layer in Keras: each neuron takes the full input vector. Its size need not equal the input size. The slides contrast this practical layout with the placeholder view.
- Hidden layer: any layer between input and output. It extracts patterns from its inputs. Each layer may hold a different neuron count.
- Output layer: the last layer. It emits one or more values from the previous layer.
A first input vector feeds three input neurons in the slide sketch. Each dense neuron would instead see the whole triple.
Three aspects of a modelSearch on YouTube
Slide lists three model aspects: synaptic interconnections, training rules for weight updates and activation functions. Later lectures vary each aspect.
Feedforward and feedback networksSearch on YouTube
Interconnections fall in two groups: feedforward and feedback.
| Feedforward | Feedback |
|---|---|
| Data flow one way (input to hidden to output) | Outputs return as inputs (same or earlier layer) |
| No cycles or loops | Loops carry past information forward |
| Sequential Dense models | Recurrent and dynamic networks |
| Fixed-size classification and regression | Sequences: time series, language, speech |
Feedforward types: single-node network (linear perceptron), single-layer network and multilayer network. Feedback types: single node with self-feedback, single-layer recurrent network and multilayer recurrent network. Lateral feedback returns output within the same layer. It models competition or cooperation (stronger neurons suppress weaker ones through lateral inhibition). Self-feedback returns one output to its own neuron. Cross-neuron feedback sends outputs to other neurons in the same or earlier layers. Recurrent neural networks (RNNs) process sequences with such loops. Variants named in the slides: LSTM, GRU and bidirectional RNNs. A single-layer perceptron has no hidden layer (input to output). Its output layer may hold several perceptrons. A multilayer perceptron (MLP) adds hidden layers. It handles linear and nonlinear functions.
F-F-F, F-R-M: loops or no loops
Feedforward: single-node, single-layer, multilayer (no loops) · Feedback: self, recurrent single-layer, multilayer (loops back).
Quick self-testSearch on YouTube
1. Map each artificial part (input, weight, sum, activation, output) to its biological part.
Inputs map to dendrites. Weights map to synaptic strength. Sum maps to the cell body. Activation maps to firing. Output maps to the axon.
2. Differentiate the MP neuron from the Rosenblatt perceptron in three points.
MP uses Boolean inputs and fixed weights with no learning. The perceptron accepts real inputs and learns weights and bias. MP sets the threshold by hand, while the perceptron shifts it through .
3. Weights are with threshold . Compute the outputs for and . Which gate is it?
sums to , so output is . sums to , so output is . The full table is AND.
4. Solve for OR: which inequality does give, and does satisfy all rows?
gives . The triple gives , , , across the four rows. All four tests pass, so it implements OR.
5. Starting from , what is for OR input and what is the update?
predicts against true . Add the input: becomes .
6. With , what does PLA do on OR input , and why?
predicts against true . Subtract the input : becomes . Subtraction fixes false alarms.
7. Compute and to three decimals. What trend do they show?
and . Activity rises with . The sigmoid grades the response instead of switching hard.
8. Three step neurons give how many patterns, and three 10-level sigmoid neurons give how many?
Step gives patterns. Graded gives patterns. More levels expand the solution space.
9. Why does PLA converge on OR but never settle on overlapping classes?
OR is linearly separable, so a separator exists and PLA makes finite updates. Overlapping classes admit no separator, so mistakes never end and updates cycle forever.
10. Prove with four inequalities that no single perceptron implements XOR.
XOR needs , , , . The middle rows force . The clash proves the need for hidden layers.
- The artificial neuron copies biology: inputs (dendrites), weights (synapses), sum (cell body), activation (firing), output (axon).
- The MP neuron (McCulloch and Pitts, 1943) uses Boolean inputs and a fixed threshold. It learns nothing.
- AND with weights needs threshold . Only reaches it.
- The perceptron (Rosenblatt, 1958) learns weights and bias. It handles only linear boundaries.
- Step gives hard or . Sigmoid grades activity (for example ).
- Bias form: with . Fire when .
- The boundary is . Two inputs give a line, three give a plane, more give a hyperplane.
- OR needs , , , . Both and pass.
- PLA adds the input on a miss and subtracts it on a false alarm. It stops when all rows pass.
- PLA converges in finite steps only for finite linearly separable sets. XOR is the canonical failure ( clashes with ).
But what is a neural network?
Perceptron Explained Visually