evie-optim
Evie: a risk-sensitive modulation of Adam-style optimizers for stochastic optimization, based on a risk-sensitive (Jacobson–Whittle) control formulation of neural network training. Evie multiplies the usual adaptive step by a noise-dependent, shrink-only gate: coordinates with higher gradient-noise variance get shrunk more.
For a variant that also allows bounded amplification on low-variance
coordinates, see the companion package
evie-amplify-optim.
Install
pip install evie-optim
Usage
import torch
from evie_optim import EvieOptimizer
model = torch.nn.Linear(10, 1)
optimizer = EvieOptimizer(model.parameters(), lr=1e-3, target_wp=0.85)
for step, (x, y) in enumerate(dataloader):
optimizer.zero_grad()
loss = torch.nn.functional.mse_loss(model(x), y)
loss.backward()
optimizer.step()
# Calibrate gamma0 once, early in training (paper uses step 100-150).
# Before this call, Evie behaves like plain AdamW.
if step == 125:
optimizer.calibrate_gamma0()
How it works
Evie treats mini-batch gradient noise as a stochastic disturbance in a control formulation of training, and derives a closed-form gain from the corresponding risk-sensitive Riccati equation. The practical update is:
sigma_t^2 = max(m2_hat - m1_hat^2, 0) # gradient-variance estimate
gamma_t = gamma0 / (1 + gamma0 * sigma_t^2) # adaptive risk-aversion
well_pos = 1 - gamma_t * sigma_t^2 # in (0, 1]
update = -lr * m1_hat * sqrt(well_pos) / sqrt(m2_hat)
gamma0 is calibrated once, from a separate fast-EMA variance estimate,
so that well_pos starts near target_wp at the calibration step.
Because well_pos <= 1 always, Evie can only shrink the corresponding
AdamW step — it never amplifies. See evie-amplify-optim for a variant
that removes this restriction.
API
EvieOptimizer(params, lr=1e-3, gamma0=1.0, target_wp=0.85, beta1=0.9, beta2=0.999, eps=1e-8, weight_decay=0.0, fast_beta=0.9)
lr: learning rate.gamma0: initial risk-aversion ceiling; overwritten bycalibrate_gamma0().target_wp: target well-posedness factor used during calibration.beta1,beta2: Adam moment decay rates.weight_decay: decoupled weight decay (AdamW-style).fast_beta: decay rate for the separate fast-EMA variance estimate used only for calibration.
optimizer.calibrate_gamma0()
Call once, partway through training, to set gamma0 from the observed
gradient variance. Safe to call only after at least one step().
License
MIT
Metadata
Release files for evie-optim 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| evie_optim-0.1.0.tar.gz | 9.3 kB | Without provenance | Details for evie_optim-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| evie_optim-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for evie_optim-0.1.0-py3-none-any.whl |
Total release size: 15.2 kB
Release files / evie_optim-0.1.0.tar.gz
| Download URL | evie_optim-0.1.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bcafae29ce90cf6e28e4aeba6899e338896cdc31794c3d840928c17d70aabd2
|
|
BLAKE2b-256 checksum How to use checksums |
b920f7f70522a318aa32b598da3f1abd0e71c17c395e54382aa40149036ece1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / evie_optim-0.1.0-py3-none-any.whl
| Download URL | evie_optim-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ac5e791490827a7362890a98cd87b44e969f008a8ff8c35509ce56b9e648301
|
|
BLAKE2b-256 checksum How to use checksums |
7843a911619a85fef098f2fc8eebda48d6858f4fd115ab9600bdbe7fba2de012
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for evie-optim 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.