A minimal scalar-valued autograd engine with neural network primitives, built for learning purposes.
Project description
learngrad
A minimal scalar-valued autograd engine with neural network primitives, built for learning purposes. Inspired by micrograd.
Install
pip install learngrad
What's inside
Value— scalar with automatic differentiation via backpropMLP— multi-layer perceptron built on top ofValue- Optimizers —
SGD,SGDMomentum,RMSProp,Adam
Quick example
from learngrad.engine import Value
from learngrad.nn import MLP
from learngrad.optimizers import Adam
# Autograd
x = Value(2.0)
y = x ** 2 + x * 3
y.backward()
print(x.grad) # dy/dx = 2x + 3 = 7.0
# Neural net
model = MLP(2, [4, 4, 1])
opt = Adam(model.parameters(), lr=1e-3)
x = [Value(1.0), Value(0.5)]
out = model(x)
out.backward()
opt.step()
Requirements
- Python >= 3.10
- numpy
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
learngrad-0.2.0.tar.gz
(4.6 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 learngrad-0.2.0.tar.gz.
File metadata
- Download URL: learngrad-0.2.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
836c30036d4895c0e4603789522c00ba65f45b781197c10c2839be4392f17a83
|
|
| MD5 |
ecca7c6b7ceff1d78d97a6c746629afc
|
|
| BLAKE2b-256 |
9e8edfaa99ca15c2c12c516cedfc3ae32867ec84f8f621d4a8d198c1be17a8db
|
File details
Details for the file learngrad-0.2.0-py3-none-any.whl.
File metadata
- Download URL: learngrad-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6854941ba743bba3312e16615dd46c15f4c64693f64c8f2f48532c184fdbd45
|
|
| MD5 |
d28fcd7949ce622619ee6570462a33fd
|
|
| BLAKE2b-256 |
3223af9148ff0e7534e8cc687bc4eeab8156bab72b0aa5f032df1daaa2fb8b5d
|