Skip to main content

Lightweight gradient descent optimizer implemented in Rust

Project description

liteopt

A lightweight optimization library written in Rust with Python bindings.

Installation

pip install liteopt

Usage

import liteopt

def f(x):
    x0, x1 = x
    return (1.0 - x0)**2 + 100.0 * (x1 - x0**2)**2

def grad(x):
    x0, x1 = x
    df_dx = -2.0 * (1.0 - x0) - 400.0 * x0 * (x1 - x0**2)
    df_dy = 200.0 * (x1 - x0**2)
    return [df_dx, df_dy]

x0 = [-1.2, 1.0]
x_star, f_star, converged = liteopt.gd(f, grad, x0, step_size=1e-3, max_iters=200_000, tol_grad=1e-4)
print(converged, x_star, f_star)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

liteopt-0.1.6.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

liteopt-0.1.6-cp313-abi3-macosx_11_0_arm64.whl (242.2 kB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

File details

Details for the file liteopt-0.1.6.tar.gz.

File metadata

  • Download URL: liteopt-0.1.6.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for liteopt-0.1.6.tar.gz
Algorithm Hash digest
SHA256 ff0b4ed159d53aba6dfa6d24bf5c31dc1670a35eee6b1b127c8579502cc704d1
MD5 a976aa501aa16d1a8f895cc0549a9e8e
BLAKE2b-256 954df649110116e86139175050a938caaf5fb7a9aaf77e990c23d5466d703af6

See more details on using hashes here.

File details

Details for the file liteopt-0.1.6-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for liteopt-0.1.6-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ea9e416fdd230c97cf6dbf9146ffc850f87af8f4474bf8b94330d7b1c2f896d
MD5 e0146d6b66b80a732dfc077529a3a06a
BLAKE2b-256 8cdd5d1fe1c438eb006b4b9a4948e982d1fb29f6f7e69c5074e6867cadc776db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page