Day 3 Quest
Furnace Ticks: Train the Neuron by Hand
Quest: Can we train Bolt's whole brain one furnace tick at a time?
Day 2 taught one weight how to walk downhill.
Today we put that idea into Bolt's full play-outside neuron: three stacks (sunny, homework, rain), one bias dust, and the six-example chest from Day 1.
Franklin still walks Craft Lab, talks to the Training Golem, and presses ONE FURNACE TICK. No magic button that hides a thousand epochs. We watch each nudge.
If I press the furnace a lot, will rain get a torch again?
Craft Lab World ยท Day 3 quest
CRAFT LAB WORLD
Desktop: WASD / arrows. Touch: joystick. Walk to the Training Golem.
Franklin Track
- Walk to the Training Golem.
- Open the furnace.
- Press ONE FURNACE TICK (or ร5 / ร10 when you get the idea).
- Watch loss go down and hearts fill up.
- Watch the rain weight. When it goes negative, a redstone torch appears.
- Check the chest: each row shows Bolt's guess right now.
Same adventure world as Day 2. Harder brain. Still your hands on the furnace.
Dad Track
One furnace tick = one batch gradient step over all six examples:
for each example:
z = xยทw + b
p = sigmoid(z)
error = p - y
average the gradients
w := w - lr * grad_w
b := b - lr * grad_b
Defaults match Day 1's playground start (w โ [0.05, -0.03, 0.08], b = 0, lr = 0.5). Still no PyTorch.
Franklin's Question
Is a furnace tick the same as the AUTO TRAIN steps from yesterday?
Yes in spirit. Yesterday: one weight, one toy target. Today: four parameters, six real examples, same "nudge downhill" idea.
Could Franklin explain it back?
"Each furnace tick looks at every example, sees how wrong Bolt is, and gently changes all the stacks so next time he is a little less wrong."
Scientific method (tiny)
- QUESTION โ Does stepping the neuron by hand drive loss under ~0.36?
- HYPOTHESIS โ Yes within about 40 ticks at lr=0.5.
- EXPERIMENT โ Run furnace ticks from the Day 1 starting weights.
- CONTROL โ Same dataset and learning rate.
- MEASUREMENT โ Mean binary cross-entropy loss.
- RESULT โ Watch the quest meter (and the Python script).
- CONCLUSION โ Batch GD works without a framework.
- NEXT QUESTION โ What does each weight mean after training? (Day 4.)
Item crafted
Item crafted!
Furnace Ticket
One punch = one furnace tick. Spend them watching Bolt learn the play-outside chest by hand.
- Batch Gradient I
- Epoch Sense I
Achievement Get!
Furnace Master
The command block
day03_neuron_steps.py"""
Day 3: train the play-outside neuron ourselves, one furnace tick at a time.
No framework. Same maths as the browser quest.
z = xยทw + b
prediction = sigmoid(z)
loss = mean binary cross-entropy
one tick = one batch gradient step over all 6 examples
"""
import math
X = [
[1.0, 1.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 0.0],
]
Y = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
weights = [0.05, -0.03, 0.08]
bias = 0.0
lr = 0.5
def sigmoid(z: float) -> float:
z = max(-20.0, min(20.0, z))
return 1.0 / (1.0 + math.exp(-z))
def predict(row, w, b):
z = row[0] * w[0] + row[1] * w[1] + row[2] * w[2] + b
return sigmoid(z)
def loss(w, b):
total = 0.0
for row, y in zip(X, Y):
p = predict(row, w, b)
total += -(y * math.log(p + 1e-8) + (1 - y) * math.log(1 - p + 1e-8))
return total / len(X)
def one_tick(w, b):
n = len(X)
preds = [predict(row, w, b) for row in X]
errors = [p - y for p, y in zip(preds, Y)]
w_grad = [0.0, 0.0, 0.0]
b_grad = 0.0
for i, row in enumerate(X):
for j in range(3):
w_grad[j] += row[j] * errors[i]
b_grad += errors[i]
w_grad = [g / n for g in w_grad]
b_grad /= n
new_w = [w[j] - lr * w_grad[j] for j in range(3)]
new_b = b - lr * b_grad
return new_w, new_b, w_grad, b_grad
print(f"start loss = {loss(weights, bias):.4f}")
print(f"start weights = {weights} bias = {bias}")
for step in range(1, 41):
weights, bias, wg, bg = one_tick(weights, bias)
if step in (1, 5, 10, 20, 40):
print(
f"tick {step:2d} loss={loss(weights, bias):.4f} "
f"w={([round(x, 3) for x in weights])} b={bias:.3f} "
f"rain_w={weights[2]:.3f}"
)
print("\nFinal decisions (threshold 0.5):")
for row, y in zip(X, Y):
p = predict(row, weights, bias)
print(f" {row} -> {p:.3f} truth={int(y)} guess={int(p >= 0.5)}")
python3 content/lab/days/day-003/day03_neuron_steps.pyNo packages. Print loss every few ticks and confirm rain's weight goes negative.
Dad's Lab Notes (tap to open)
- Wanted to learn
- Apply Day 2's gradient idea to the full play-outside neuron, step by step.
- Learned
- One furnace tick = one batch update over all examples. Loss falls; rain weight goes negative (torch) from data alone.
- Built
- neuronTrain.ts, NeuronStepQuest, Day3Playground, Furnace Ticket item, Glowstone Eyes, day03_neuron_steps.py.
- Confused me
- Why average gradients over the six rows? (Batch GD: one shared nudge from the whole chest.)
- Failed
- Nothing catastrophic. Too few ticks leave guesses messy; that is the point of watching.
- Taught Franklin
- Franklin: each tick looks at every example and gently changes all stacks so Bolt is less wrong next time.
- Tomorrow
- Multiple inputs, weights and bias: interpret what each stack learned.
Tomorrow
Day 4: multiple inputs, weights and bias. Dig into what each stack means after training.
