Skip to main content

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 backprop
  • MLP — multi-layer perceptron built on top of Value
  • 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_circles dataset
  • 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

Metadata

Release files for learngrad 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for learngrad 0.2.1
File Size Uploaded Provenance Actions
learngrad-0.2.1.tar.gz 4.8 kB With provenance Details for learngrad-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for learngrad 0.2.1
File Interpreter ABI Platform Actions
learngrad-0.2.1-py3-none-any.whl Python 3 none any Details for learngrad-0.2.1-py3-none-any.whl

Total release size: 10.9 kB

Release files / learngrad-0.2.1.tar.gz

Download URL learngrad-0.2.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2dddb157f1c1c4a96099a4c4c1bc75f2e1145b1c0b019c10f70832c34ca9b731
BLAKE2b-256 checksum
How to use checksums
a04b772d34eba751a9a24c9f92b4b109739bb430f191d0a9417b2ff3204e89fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Release files / learngrad-0.2.1-py3-none-any.whl

Download URL learngrad-0.2.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1126e6971fceef3809897bfc785eb3ff69f1c69c4a25a916b3e4b1d641a09ea5
BLAKE2b-256 checksum
How to use checksums
3d5cab215ff6325f53892edcf2077b2e5ad68e9bbd674b9ac3675ab9e7c6c8fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Security for learngrad 0.2.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for learngrad-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page