Optimizer state is information an optimizer keeps while training. It is distinct from a model’s weights and biases. The PyTorch examples show how an optimizer receives parameters and updates them, but do not inspect its internal state or show how to save it. section 6.2.2
An optimizer in a training loop
For a linear model, create `optimizer = optim.SGD(linear_model.parameters(), lr=1e-2)`. Each training iteration calls `optimizer.zero_grad()`, computes a loss, calls `loss.backward()`, then calls `optimizer.step()`. Backward fills the parameters’ `grad` attributes; `step()` uses those gradients to change the parameters. The example does not expose any separate optimizer state. section 6.2.2
A model with multiple linear layers follows the same pattern: `model.parameters()` supplies their weights and biases to the optimizer. AdamW and SGD are also suggested for comparison during segmentation training, but no procedure for saving or restoring either optimizer is shown. section 6.3.2 section 15.10
