Download week02.py. With NumPy, scikit-learn, and PyTorch installed, run python week02.py --lesson 3. The lab rebuilds the Week 1 generated data and exact split, fits training-only standardization, trains a small nonlinear classifier, and compares the selected model with logistic regression.
Read the loop: optimizer.zero_grad clears storage, model(features) performs a forward pass, loss.backward computes derivatives, and optimizer.step updates weights. Validation runs under evaluation mode with disabled gradient recording. A copied state dictionary stores the best validation checkpoint; a state dictionary maps parameter names to tensors.
Inspect the printed train/validation losses and final confusion counts. The lab checks finite losses, shape agreement, and stable evaluation behavior; it reports actual classification scores rather than asserting a preferred winner. Save the commands and output. Extend this same artifact by comparing two learning rates on validation data and then report the final selected configuration once on test data.