LeanPass offers a lightweight, NumPy-based approach to automatic differentiation for neural network experiments. Its transparent design and minimal dependency footprint make it ideal for learning and prototyping, allowing users to explore neural network concepts without the complexity of larger frameworks.
LeanPass is a lightweight and transparent library designed for neural network experiments, built using NumPy. This library is especially well-suited for small-scale projects and educational purposes, offering a clear and readable codebase that makes it easy to understand the underlying mechanics of automatic differentiation.
LeanPass offers various capabilities:
To get started with LeanPass, a simple example can be utilized as follows:
from leanpass import Tensor, nn
x = Tensor([[1.0, 2.0]], requires_grad=False)
model = nn.MLP([2, 16, 3])
logits = model(x)
print(logits)
A demonstration of a complete training loop is provided, which includes synthetic data and visible loss metrics:
import numpy as np
from leanpass import Tensor, nn, optim
np.random.seed(1)
x_data = np.random.randn(150, 2)
y_data = np.eye(3)[np.random.randint(0, 3, 150)]
model = nn.MLP([2, 16, 3])
optimizer = optim.Adam(model.parameters(), lr=0.01)
for step in range(100):
x = Tensor(x_data, requires_grad=False)
y = Tensor(y_data, requires_grad=False)
logits = model(x)
loss = nn.cross_entropy_loss(logits, y)
optimizer.zero_grad()
loss.backward()
optimizer.step()
if step % 20 == 0:
print(f"Step {step:03d} — Loss: {loss.data:.6f}")
Comprehensive documentation, including API references and hands-on guides for various tasks, is available at LeanPass Documentation.
LeanPass seeks to empower users to explore neural networks efficiently while minimizing complexity, making it an excellent resource for educators, researchers, and hobbyists alike.
No comments yet.
Sign in to be the first to comment.