This loop computes pred once, above the loop, so every step reuses
a stale prediction — the loss explodes instead of shrinking. Move the
forward pass inside the loop so pred is recomputed each step from
the updated w. (Delete line 2 and make pred = w * x the first line
inside the for body.)
Expected output:
0.0
The break is on line 2 — but read the whole snippet first.