SGD con momentum
Renda più uniformi gli aggiornamenti per superare il rumore
SGD con momentum è una lezione Deep Learning Academy gratuita su CoddyKit. Questa è la lezione 1 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.
Plain SGD Forgets
Vanilla SGD steps using only the current gradient. Every update starts from scratch, so a noisy slope makes it wobble and crawl toward the minimum.
Borrow Some Inertia
Momentum gives SGD memory. It keeps a running average of past gradients and rolls in that direction, like a ball gathering speed downhill.
The Velocity Vector
Momentum tracks a velocity that blends the old velocity with the new gradient. The weights then move by that smoothed velocity each step.
v = beta * v + grad
w = w - lr * vThe Beta Knob
The momentum coefficient beta sets how much past steps count. A common value is 0.9, meaning most of the velocity carries over.
Smooths Out Noise
Because momentum averages many gradients, random noise in any single batch mostly cancels. The path to the minimum becomes smoother and steadier.
Rolls Past Small Bumps
Built-up speed lets the optimizer coast through tiny dips and flat spots that would stall plain SGD. The ball does not stop at every pebble.
Turn It On in PyTorch
You do not code this by hand. Just pass momentum to the built-in SGD optimizer and PyTorch tracks the velocity for you.
opt = torch.optim.SGD(model.parameters(), lr=0.01, momentum=0.9)Nesterov Looks Ahead
A sharper variant, Nesterov momentum, peeks at where the velocity is heading before measuring the gradient. It often converges a touch faster.
opt = torch.optim.SGD(model.parameters(), lr=0.01, momentum=0.9, nesterov=True)Mind the Overshoot
Too much speed can carry you past the valley floor. If loss bounces or diverges, lower the learning rate or trim momentum a little.
Why It Still Matters
Even with fancy optimizers around, SGD with momentum remains a strong baseline and often generalizes beautifully on vision models.
A Faster Descent
The payoff is real: momentum usually reaches a good minimum in fewer epochs than plain SGD, with less zig-zagging along the way.
Quick Check
Make sure momentum's role is clear.
Recap
Momentum gives SGD a velocity that blends past gradients, smoothing noise and coasting past small bumps. Set momentum near 0.9 for a faster, steadier descent. 🏂
Domande Frequenti
La lezione «SGD con momentum» è gratuita?
Sì — il testo completo di «SGD con momentum» è 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 «SGD con momentum»?
Renda più uniformi gli aggiornamenti per superare il rumore 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 1 di 4.
Quanto tempo richiede la lezione «SGD con momentum»?
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