ProdigyOpt Optimizer

1.1.2 · active · verified Thu Apr 16

ProdigyOpt is an Adam-like optimizer for neural networks, designed for high performance and memory efficiency. It features adaptive learning rate estimation and implements decoupled weight decay. The current version is 1.1.2, and releases typically focus on minor bug fixes and performance enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Prodigy optimizer with a PyTorch model and perform a single optimization step. It includes model definition, loss calculation, and the standard optimizer workflow.

import torch
import torch.nn as nn
from prodigyopt import Prodigy

# 1. Define a simple model
model = nn.Linear(10, 2)

# 2. Initialize the optimizer with model parameters
#    decouple_wd=True is default, but explicitly shown for clarity
optimizer = Prodigy(model.parameters(), lr=1e-3, decouple_wd=True)

# 3. Define a loss function
loss_fn = nn.MSELoss()

# 4. Prepare dummy data
inputs = torch.randn(5, 10)
targets = torch.randn(5, 2)

# 5. Perform a training step
optimizer.zero_grad() # Clear gradients
outputs = model(inputs) # Forward pass
loss = loss_fn(outputs, targets) # Compute loss
loss.backward() # Backward pass to compute gradients
optimizer.step() # Update model parameters

print(f"Loss after one step: {loss.item():.4f}")

view raw JSON →