PRNG & Random Sampling
Set up JAX's functional PRNG: wrap seeds, split keys, and sample random tensors.
Implement initialization, forward passes, loss, autodiff, and pure functional SGD updates in JAX.
Every source step is its own lesson with intuition, concepts, correctly rendered MathJax mathematics, implementation, tests, mistakes, and a checkpoint.
Set up JAX's functional PRNG: wrap seeds, split keys, and sample random tensors.
Generate input features, assign deterministic class labels, and one-hot encode targets.
Initialize a single linear layer and extend to a full MLP parameter list.
Implement the linear layer, ReLU, softmax, and the full MLP forward pass.
Compute log-softmax, mean cross-entropy loss, and classification accuracy.
Wrap the loss for autodiff, take gradients with jax.grad, and apply SGD updates.
Combine the pieces into a training step, an epoch loop, and a prediction function.