Page 6 of 8~112 min topic

Neural nets by building

Instrument the single-neuron trainer

Page 6 adds signals that distinguish bad input from component failure in the single-neuron logic-gate trainer.

~14 min this pageTesting and observability

1Learn the idea

Read

Emit stage signals

Instrument the single-neuron logic-gate trainer so a run records enough structure to debug offline: counts, latency if relevant, pass/fail of final predictions match gate table, and a stable stage name. Redact secrets and raw credentials from every event.

Read

Emit and assert

trace={'epoch':200,'loss':0.14,'grad_norm':0.03,'min_margin':0.31}
assert trace['grad_norm']>0 and trace['min_margin']>0
print(trace)

Expected evidence: stage evidence for observability. Prefer JSON or structured text you can grep in CI over prose logs for neural-nets-by-building.

Read

Lock signals with a regression test

Turn one historical failure—especially learning rate so large weights diverge—into a test that fails if the signal disappears for the single-neuron trainer. Observability without a failing test is optional decoration; observability with a test is part of the neural-nets-by-building artifact.

Read

Lab notebook: signal schema

Draft a three-field event for the single-neuron trainer: stage, ok, and one domain field derived from final predictions match gate table; loss decreases across epochs. Add fixture_id or docs_version when content can change. Explicitly list fields that must never appear (tokens, passwords, raw prompts) because hard-coding 'trained' weights without a verifiable training loop is in scope for this lab.

Wire one assertion that fails if the single-neuron trainer event is missing after a run. Observability that cannot fail a test will not survive contact with a busy neural-nets-by-building repository.

Read

Worked judgment

Imagine a teammate opens only your event stream after a bad deploy. Could they tell whether AND gate truth table was wrong, whether learning rate so large weights diverge, or claiming XOR success with one neuron returned, or whether hard-coding 'trained' weights without a verifiable training loop slipped through? If not, rename fields until those three stories are distinguishable.

Read

Why this stage matters for the single-neuron trainer

At the testing and observability stage for neural-nets-by-building, the job is narrower than finishing a product demo. You are creating one progressive evidence piece about AND gate truth table that later pages inherit without redefining success. Keep that fixture small enough to inspect by hand, keep outputs copy-pasteable as text, and refuse to narrate this baseline as if it were a production SLA: untrained weight predictions on the gate table.

For this page specifically, success looks like a structured event schema locked by a test while still centering the user decision to learn weights for a linearly separable gate by gradient steps you can print. If you cannot point to a file, command, or assertion that proves that for the single-neuron trainer, stay on this page instead of advancing.

Glossary: deep learning · Glossary: gradient descent

Previous · Next

Go deeper

Before you start

Why this matters

Write the single log line or metric event that would tell you whether a bad result came from input vs implementation for the single-neuron trainer. If your line could not tell them apart, redesign it before coding.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Can input faults be distinguished from component faults in the event?
2. Are secrets redacted from logs?
3. Is there a test that fails if the signal vanishes?
4. Does the event still reference the decision: learn weights for a linearly separable gate by gradient steps you can print?

All responses are required.