Adam e AdamW spiegati
Learning rate adattivi e weight decay disaccoppiato
Adam e AdamW spiegati è una lezione Deep Learning Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Deep Learning Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Deep Learning Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
One Rate Per Weight
SGD uses a single learning rate for every parameter. Adam adapts the step size for each weight on its own, based on that weight's gradient history.
Two Moving Averages
Adam tracks two running averages: the mean of gradients and the mean of their squares. Together they form the first and second moments.
First Moment Is Momentum
The first moment is basically momentum, the smoothed average of recent gradients. It decides the overall direction each weight should move.
Second Moment Scales Steps
The second moment estimates each gradient's size. Adam divides by its square root, so noisy weights take smaller steps and quiet ones take larger.
The Betas
Two decay rates, the betas, control those averages, typically 0.9 and 0.999. They balance how much recent versus older gradients matter.
Bias Correction
The averages start at zero, so early steps look too small. Adam applies a bias correction to fix this so updates are sane from step one.
Use It in PyTorch
One line gives you Adam. The default learning rate of 0.001 works well across a huge range of models, which is why it is so popular.
opt = torch.optim.Adam(model.parameters(), lr=1e-3)Adam's Weight Decay Flaw
Classic Adam mixes weight decay into the gradient, where the adaptive scaling distorts it. The regularization ends up weaker than you intended.
AdamW Fixes It
AdamW decouples weight decay from the gradient step and applies it directly to the weights. The decay now works as a clean, predictable shrink.
opt = torch.optim.AdamW(model.parameters(), lr=1e-3, weight_decay=0.01)The Modern Default
For transformers and most large models, AdamW is the standard choice. Reach for it first whenever you want fast, reliable convergence.
Adaptive, With Caveats
Adam often trains faster than SGD, yet plain SGD with momentum can generalize better on vision tasks. Try both when accuracy really counts.
Quick Check
Pin down the Adam to AdamW difference.
Recap
Adam adapts a learning rate per weight using gradient mean and variance, while AdamW fixes its weight decay. AdamW is today's go-to optimizer. ⚙️
Domande Frequenti
La lezione «Adam e AdamW spiegati» è gratuita?
Sì — il testo completo di «Adam e AdamW spiegati» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Deep Learning Academy, passa a CoddyKit PRO. Il corso Deep Learning Academy include 4 lezioni in totale.
Cosa imparerò in «Adam e AdamW spiegati»?
Learning rate adattivi e weight decay disaccoppiato Eserciti Deep Learning Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Deep Learning Academy?
Non è richiesta alcuna esperienza precedente. Deep Learning Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Adam e AdamW spiegati»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Deep Learning Academy?
Sì. Ogni lezione Deep Learning Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- SGD con momentum
- Adam e AdamW spiegati
- Weight decay e regolarizzazione L2 a confronto
- Scheduler del learning rate e warmup