liveBook · Manning

AdamW

As explained in Build a Large Language Model (From Scratch)

An adaptive optimization algorithm that maintains historical information to adjust learning rates for neural-network parameters.

AdamW is an Adam variant used to train neural networks. Its weight-decay approach penalizes larger weights, helping reduce model complexity, limit overfitting, and improve generalization. section 5.2

PyTorch configuration

optimizer = torch.optim.AdamW(model.parameters(), lr=0.0004, weight_decay=0.1). Pass this optimizer to the training function, which calls zero_grad(), backpropagation, and step() for each batch.

How Build a Large Language Model (From Scratch) covers it

How deep it goes
Defines the regularization rationale and shows configuration, but stops short of deriving AdamW update equations.
Examples
Uses a PyTorch GPTModel configuration with learning rate 0.0004, weight decay 0.1, and ten training epochs.
What it assumes
Assumes familiarity with neural-network training, gradients, losses, model parameters, and PyTorch optimizers.
What you can do after
Operate/configure AdamW in a PyTorch training loop and monitor losses for generalization problems.
How it connects
Connects Adam, weight decay, regularization, overfitting, generalization, GPT models, and training loops.

Also explained in

Compare how 3 books explain AdamW →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Large Language Model (From Scratch). The section links point to the parts of the book it draws on.