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()
Demo
notebooks/demo.ipynb walks through a full training example:
- Binary classification on the
make_circlesdataset - MLP with hinge loss and L2 regularization
- Mini-batch training loop with Adam
- Train/val accuracy tracking
- Decision boundary visualization
Reaches ~94% val accuracy in 100 epochs.
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
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.1.tar.gz.
File metadata
- Download URL: learngrad-0.2.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dddb157f1c1c4a96099a4c4c1bc75f2e1145b1c0b019c10f70832c34ca9b731
|
|
| MD5 |
7af342669ddd0b1229835b5f02821127
|
|
| BLAKE2b-256 |
a04b772d34eba751a9a24c9f92b4b109739bb430f191d0a9417b2ff3204e89fb
|
Provenance
The following attestation bundles were made for learngrad-0.2.1.tar.gz:
Publisher:
publish.yml on devparikh0506/learngrad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
learngrad-0.2.1.tar.gz -
Subject digest:
2dddb157f1c1c4a96099a4c4c1bc75f2e1145b1c0b019c10f70832c34ca9b731 - Sigstore transparency entry: 1358947688
- Sigstore integration time:
-
Permalink:
devparikh0506/learngrad@13930e9d08f524c56b38d75e9ac148fbbfdaf6ef -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/devparikh0506
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13930e9d08f524c56b38d75e9ac148fbbfdaf6ef -
Trigger Event:
push
-
Statement type:
File details
Details for the file learngrad-0.2.1-py3-none-any.whl.
File metadata
- Download URL: learngrad-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1126e6971fceef3809897bfc785eb3ff69f1c69c4a25a916b3e4b1d641a09ea5
|
|
| MD5 |
c0221673c94e4c2588f14306db4164e6
|
|
| BLAKE2b-256 |
3d5cab215ff6325f53892edcf2077b2e5ad68e9bbd674b9ac3675ab9e7c6c8fe
|
Provenance
The following attestation bundles were made for learngrad-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on devparikh0506/learngrad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
learngrad-0.2.1-py3-none-any.whl -
Subject digest:
1126e6971fceef3809897bfc785eb3ff69f1c69c4a25a916b3e4b1d641a09ea5 - Sigstore transparency entry: 1358947729
- Sigstore integration time:
-
Permalink:
devparikh0506/learngrad@13930e9d08f524c56b38d75e9ac148fbbfdaf6ef -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/devparikh0506
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13930e9d08f524c56b38d75e9ac148fbbfdaf6ef -
Trigger Event:
push
-
Statement type: