PYTHON · NUMPY
Train for ternary: QAT matches FP32

A 2->16->2 MLP on XOR-quadrants (label 1 when x*y<0 — the two off-diagonal quadrants, a problem no linear model solves). You train with QAT+STE: the forward pass ternarizes the weights, the backward pass updates FP32 shadow weights as if ternarize were the identity, and shadow weights are clipped each step. Everything is numpy and deterministic (SEED=3); a one-line np.seterr keeps numpy's spurious matmul FPE flags out of your output. Fill the one gap — the ternarize scale — and evaluate with the ternary weights. PASS when ternary test accuracy >= 0.90.

You read

the arrays and values already in scope

You change

the code you write in each cell

Fixed

the dataset and the checks that grade you