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
Release history Release notifications | RSS feed
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.3.tar.gz
(12.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file liteopt-0.1.3.tar.gz.
File metadata
- Download URL: liteopt-0.1.3.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1debe67299fb9c18507daf359ef1170f8dafb7a23858441e68a4aa69efd77690
|
|
| MD5 |
dc84c19d9c9f3e31df5b5bb8fa49b97a
|
|
| BLAKE2b-256 |
ae0c29a049bb75086a82c8cf05f5a43d074fc014cfe4c87dc02141a8e6eebda9
|
File details
Details for the file liteopt-0.1.3-cp313-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: liteopt-0.1.3-cp313-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 220.6 kB
- Tags: CPython 3.13+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e750537d656c74a69e8900344f47d3ca60f8d50b84ced44a2e0b0f2cdb1f9de1
|
|
| MD5 |
80ef31703622ec6b46ed2a8f7ef34ee3
|
|
| BLAKE2b-256 |
a2cf0a7bc875ea74327e8861f115efe2211332ebfade5f6d2fd44909fdab7ad4
|