Skip to main content

Crate zyx_optim

Crate zyx_optim 

Source
Expand description

§zyx-optim

Optimizers for the zyx machine learning library.

This crate provides a collection of popular gradient-based optimization algorithms designed to work seamlessly with zyx’s autograd system. All optimizers implement the Module trait.

§Features

§Optimizers

  • Adam — Adaptive moment estimation
  • AdamW — Adam with weight decay decoupling
  • RMSprop — Root mean square propagation
  • SGD — Stochastic gradient descent

§Python Bindings

  • py feature enables Python interoperability via pyo3

§Usage

use zyx_optim::{Adam, SGD};

// Create optimizer with default parameters
let mut optim = Adam::default();

// Configure hyperparameters
optim.learning_rate = 0.001;      // learning rate
optim.betas = (0.9, 0.999);       // first and second moment decay
optim.eps = 1e-8;                 // numerical stability
optim.weight_decay = 0.01;        // L2 weight decay
optim.amsgrad = true;             // enable AMSGrad variant

§API

All optimizers implement the Module trait:

use zyx_optim::Adam;

let mut optim = Adam {
    learning_rate: 0.001,
    betas: (0.9, 0.999),
    eps: 1e-8,
    weight_decay: 0.0,
    amsgrad: false,
    m: Vec::new(),
    v: Vec::new(),
    vm: Vec::new(),
    t: 0,
};

// Configure hyperparameters
optim.learning_rate = 0.001;      // learning rate
optim.betas = (0.9, 0.999);       // first and second moment decay
optim.eps = 1e-8;                 // numerical stability
optim.weight_decay = 0.01;        // L2 weight decay

§Hyperparameters

§Adam

  • learning_rate — Learning rate (default: 0.001)
  • betas — First and second moment decay (default: (0.9, 0.999))
  • eps — Numerical stability (default: 1e-8)
  • weight_decay — L2 weight decay (default: 0.0)
  • amsgrad — AMSGrad variant (default: false)

§AdamW

Same as Adam, with additional:

  • weight_decay — L2 weight decay (default: 0.0)

§RMSprop

  • learning_rate — Learning rate (default: 0.001)
  • momentum — Moving average decay (default: 0.9)
  • eps — Numerical stability (default: 1e-8)

§SGD

  • learning_rate — Learning rate (default: 0.01)
  • momentum — Momentum coefficient (default: 0.0)
  • weight_decay — L2 weight decay (default: 0.0)

§Features

  • py — Enable Python bindings via pyo3
  • std — Enables zyx-core/std (default)

§Documentation

§License

LGPL-3.0-only

Structs§

Adam
Adaptive momentum estimation optimizer
AdamW
Adaptive momentum estimation optimizer
RMSprop
RMSProp optimizer for adaptive learning rate training.
SGD
Stochastic gradient descent optimizer