# R26 Q3a

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/12/tee-c12-s6

Canonical: https://deep-learning-study-room.vercel.app/read/dl/tee/section/tee-c12-s6/

## Question

**Question (10 marks).** Train a perceptron for one epoch, η = 1, initial weights and bias 0, threshold 0. Samples: [−1,1,−1] → −1; [1,1,1] → 1; [−1,−1,1] → −1; [−1,1,1] → −1. Discuss limitations with examples.

## Answer — step by step

### Given

Train a perceptron for one epoch, η = 1, initial weights and bias 0, threshold 0.

Samples: [−1,1,−1] → −1.

[1,1,1] → 1.

[−1,−1,1] → −1.

[−1,1,1] → −1.

### To find

Process samples in order for the stated epochs and report the final weights and bias.

### Formula — which one and why

**Target-based perceptron correction.** This worked convention changes parameters only on a wrong prediction. Use the target itself as the signed multiplier; it differs from the binary error rule.

t is the bipolar target; η is the learning rate. Output is +1 above zero, −1 below zero and 0 at exactly zero.



$$
\Delta w=\eta t x,\quad\Delta b=\eta t\quad\text{on a mismatch}
$$



**Yaad rakhne ka cue:** Is convention mein galat hua toh target × input se correction.

### Solution — step by step

**State the threshold rule.** Use output +1 if z>0, −1 if z<0, and 0 at z = 0. On a mismatch use Δw = η tx and Δb = ηt; on a match make no update. η = 1. A different rule at zero can change the learning trajectory. Write your convention explicitly.

### Epoch 1, sample 1

**Step 1: copy this sample and target.**

x = [-1, 1, -1], target = -1.

**Step 2: calculate the current net.**

z = (0 × -1) + (0 × 1) + (0 × -1) + (0) = 0

**Step 3: apply the threshold.**

output = 0.

**Step 4: calculate the update multiplier.**

Update multiplier = -1

**Step 5: calculate all weight changes.**

Δw = -1 × [-1, 1, -1] = [1, -1, 1]

**Step 6: calculate the bias change.**

Δb = -1.

**Step 7: carry the updated parameters forward.**

New w = [1, -1, 1], new b = -1.

### Epoch 1, sample 2

**Step 1: copy this sample and target.**

x = [1, 1, 1], target = 1.

**Step 2: calculate the current net.**

z = (1 × 1) + (-1 × 1) + (1 × 1) + (-1) = 0

**Step 3: apply the threshold.**

output = 0.

**Step 4: calculate the update multiplier.**

Update multiplier = 1

**Step 5: calculate all weight changes.**

Δw = 1 × [1, 1, 1] = [1, 1, 1]

**Step 6: calculate the bias change.**

Δb = 1.

**Step 7: carry the updated parameters forward.**

New w = [2, 0, 2], new b = 0.

### Epoch 1, sample 3

**Step 1: copy this sample and target.**

x = [-1, -1, 1], target = -1.

**Step 2: calculate the current net.**

z = (2 × -1) + (0 × -1) + (2 × 1) + (0) = 0

**Step 3: apply the threshold.**

output = 0.

**Step 4: calculate the update multiplier.**

Update multiplier = -1

**Step 5: calculate all weight changes.**

Δw = -1 × [-1, -1, 1] = [1, 1, -1]

**Step 6: calculate the bias change.**

Δb = -1.

**Step 7: carry the updated parameters forward.**

New w = [3, 1, 1], new b = -1.

### Epoch 1, sample 4

**Step 1: copy this sample and target.**

x = [-1, 1, 1], target = -1.

**Step 2: calculate the current net.**

z = (3 × -1) + (1 × 1) + (1 × 1) + (-1) = -2

**Step 3: apply the threshold.**

output = -1.

**Step 4: calculate the update multiplier.**

Update multiplier = 0

**Step 5: calculate all weight changes.**

Δw = 0 × [-1, 1, 1] = [0, 0, 0]

**Step 6: calculate the bias change.**

Δb = 0.

**Step 7: carry the updated parameters forward.**

New w = [3, 1, 1], new b = -1.

**Final after exactly the requested epochs:**  w = **[3, 1, 1]**, b = **-1**. A finite number of requested epochs does not itself prove convergence or correct classification of every sample.

A single perceptron forms a weighted sum and applies a threshold. Its decision boundary is linear: w·x+b = 0. It can learn linearly separable patterns such as AND and OR under suitable learning conditions, but cannot represent XOR with one linear separator.

![Opposite corners for XOR cannot be split by one straight line](https://deep-learning-study-room.vercel.app/assets/figures/xor.svg)

Diagram: Opposite corners for XOR cannot be split by one straight line. Labels: x1 | x2 | 0 | 1 | 1 | 0 | XOR labels occupy opposite corners | 0 | 1 | 0 | 1 | One straight decision boundary cannot separate the two classes.

Opposite corners for XOR cannot be split by one straight line Tap the diagram to enlarge.

For binary AND, w₁ = w₂ = 1 and b = −1.5 give preactivations −1.5, −0.5, −0.5 and 0.5 for 00, 10, 01 and 11. A step that returns 1 at nonnegative inputs produces 0,0,0,1.

For XOR, use h₁ = step(x₁+x₂−0.5) for OR and h₂ = step(x₁+x₂−1.5) for AND. Then XOR = step(h₁−2h₂−0.5). For inputs 00,01,10,11, the hidden pairs are (0,0), (1,0), (1,0), (1,1), producing 0,1,1,0. XNOR = step(−h₁+2h₂+0.5), producing 1,0,0,1. This is a multilayer construction, not a claim that a single perceptron solves XOR.

A multilayer feedforward network adds hidden nonlinear features before the final boundary. Without hidden nonlinearities, adding linear layers still produces one affine map.

**Key correction:**  recomputing each net with the latest weights gives net values 0,0,0,−2 and final w = [3,1,1], b = −1 under the stated bipolar rule. The supplied answer-key table contains inconsistent intermediate arithmetic.
