docsapi referencedarkforest-core-optim-sgd
API Referencecrate: darkforest-coresince v0.1.0-alpha

SGD

Stochastic Gradient Descent optimizer with momentum and Nesterov acceleration.

SGD

darkforest-core module: optim since v0.1.0-alpha

Signature

rust
pub struct SGD { params: Vec<Tensor>, lr: f32, momentum: f32, dampening: f32, weight_decay: f32, nesterov: bool, velocity: Vec<Tensor> }

Overview

Stochastic Gradient Descent optimizer with momentum and Nesterov acceleration.

Invariants & Design Principles

  • Invariant: Milestone 1 parity gate passed: loss diff 1.14e-7 vs PyTorch SGD across 200 steps.

Usage Example

rust
let mut opt = SGD::new(model.parameters(), 0.01).with_momentum(0.9);

Related Components