Week 02 · lesson
Lab: Build a Two-Layer XOR Network
Mission
Build a hand-checkable layered calculation that matches all four XOR cases. You will not hide a failed row or claim that four binary cases prove anything about a deployed neural network.
Network specification
Use the step function step(z) = 1 when z ≥ 0; otherwise it returns 0.
h1 = step(x1 + x2 - 0.5) # OR-like hidden feature
h2 = step(x1 + x2 - 1.5) # AND-like hidden feature
y = step(h1 - 2h2 - 0.5) # combine the hidden features
The hidden layer changes the representation. Instead of asking one line to separate the original four points, the output unit receives two intermediate features.
Completed guided row
For x1 = 1 and x2 = 1:
h1 score = 1 + 1 - 0.5 = 1.5 → h1 = 1
h2 score = 1 + 1 - 1.5 = 0.5 → h2 = 1
y score = 1 - (2 × 1) - 0.5 = -1.5 → y = 0
The XOR target for 1,1 is 0, so this row passes.
Procedure
- Copy the four XOR input rows into a Layered Network Test Record.
- For each row, calculate the raw score and output of
h1. - Calculate the raw score and output of
h2. - Use those hidden outputs to calculate
y. - Compare
ywith the XOR target. Mark pass or fail without editing the target. - Change only the output weight on
h2from-2to-1. - Rerun all four rows and identify the first exact counterexample.
- Restore
-2and write a bounded conclusion.
Record template
| x1 | x2 | h1 | h2 | y | XOR target | Result |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | ||||
| 0 | 1 | 1 | ||||
| 1 | 0 | 1 | ||||
| 1 | 1 | 1 | 1 | 0 | 0 | pass |
Success criteria
- every raw score can be independently recalculated;
- the baseline network passes all four supplied XOR cases;
- the changed-weight run preserves at least one exact failure;
- the explanation identifies the hidden layer as a representation change; and
- the limitation rejects claims about learning quality, generalization, safety, biological brains, or larger neural networks.
Troubleshooting
If step(0) differs between group members, return to the declared rule: this
Lab defines it as 1. If the changed run still appears to pass, inspect the
1,1 row and show the raw output score. If a value changes unexpectedly,
recalculate one unit at a time instead of carrying the entire network mentally.
Safety and runtime boundary
Use only the four supplied binary cases. This deterministic paper-or-local calculation sends no data over a network, trains no model, and makes no real decision. Submit the complete table and both conclusions; a photograph of an incomplete table is not equivalent evidence.
AI Systems Lab · contract v1
XOR Layer Lab
Compare one neuron with a fixed activated two-layer network, trace every hidden value, and repair one disabled connection.
Help and boundaries
A deterministic browser simulator displays supplied forward-pass calculations. It trains no model and contacts no service.
No personal data, private prompts, or API keys. This Lab makes no hidden remote writes and does not persist your work after the page session.
No result trains a model, identifies a person, controls a device, or supports a real deployment decision.
Lab draft is active for this page session only.
Objectives
- Explain why one straight boundary cannot reproduce the supplied XOR targets.
- Trace input, hidden scores, activated hidden values, output score, and tested output.
- Compare architectures and repair one connection using all four supplied cases.
Procedure
Workbench
Trace the layers. Keep every value visible.
The target table never changes. These fixed teaching parameters were supplied; the simulator does not train them.
Local experiment · deterministic simulation
XOR Layer Simulator
Trace the same four binary targets through one neuron, activated hidden layers, or layers whose activation has been removed.
A readable explanation of the same local run.
- 01XOR TargetWhich output is supplied for this input pair?
- 02Input VectorWhich two binary values enter the architecture?
- 03OR Hidden NeuronWhat score and activated clue does h_or produce?
- 04NAND Hidden NeuronWhat score and activated clue does h_nand produce?
- 05Hidden RepresentationWhich two values reach the output layer?
- 06Output NeuronHow are the hidden values and connection weights combined?
- 07Four-Case TestHow many supplied XOR targets does this architecture reproduce?
- 08Claim BoundaryWhat does this fixed simulation fail to prove?
Read the student trace as text
robotnix-ai-lab :: local deterministic XOR network Target mapping: 00→0 · 01→1 · 10→1 · 11→0 Predict both hidden clues, then run the forward pass.
All supplied cases: 4/4 pass
| Input | h_or | h_nand | Output score | Output | Target | Test |
|---|---|---|---|---|---|---|
| [1,0] | 1.0 | 1.0 | 0.5 | 1 | 1 | PASS |
| [1,1] | 1.0 | 0.0 | -0.5 | 0 | 0 | PASS |
| [0,0] | 0.0 | 1.0 | -0.5 | 0 | 0 | PASS |
| [0,1] | 1.0 | 1.0 | 0.5 | 1 | 1 | PASS |
Lab boundary: four fixed binary cases show representation capacity, not training quality, future accuracy, understanding, fairness, safety, or deployment readiness.
Text and static fallback
Every input, score, activation, hidden value, output, target, connection weight, and test result appears as selectable text and in an accessible table.
One neuron passes 3/4; activated layers pass 4/4; layers without hidden activation pass 2/4; disabling h_nand to output also passes 2/4; restoring its weight to one returns 4/4.
Evidence record
Record only the evidence requested. Do not enter names, personal information, private prompts, or credentials. This draft stays in memory only unless you explicitly export it.
Success criteria
- The forward pass preserves every hidden and output calculation.
- All three architecture results are recorded as 3/4, 4/4, and 2/4.
- The evidence preserves the broken state, changes one weight, and retests all four cases.
- The limitation rejects training, general-performance, understanding, and deployment claims.
Complete every procedure step and required evidence field before export.
Vocabulary lab
Flip the idea, not just the card
Explain the term before you reveal the back. Then compare your explanation with the definition, example, and warning.
Read all terms without animation
- hidden unit
- An intermediate calculation whose output becomes input to a later layer. Example: h1 represents an OR-like feature and h2 an AND-like feature. Do not confuse it with: Hidden means intermediate, not unknowable or secret.
- hidden layer
- A group of intermediate units between the original inputs and final output. Example: The XOR network has the h1 and h2 units in one hidden layer. Do not confuse it with: Adding a layer does not automatically make a model accurate or safe.
- activation function
- A declared rule applied to a unit's score to produce its output. Example: The Lab step function returns one for scores at or above zero. Do not confuse it with: An activation is a mathematical operation, not attention or consciousness.
- XOR
- A binary relation that returns one when exactly one of its two inputs is one. Example: Inputs 0,1 and 1,0 are the positive XOR cases. Do not confuse it with: XOR cannot be separated by one linear boundary in the original two-input space.
- counterexample
- One valid case that contradicts a general claim. Example: A failed 1,1 row rejects the claim that the changed network implements XOR. Do not confuse it with: A counterexample disproves the broad claim; it does not explain every cause.