Skip to main content

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 backprop
  • MLP — multi-layer perceptron built on top of Value
  • OptimizersSGD, 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.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

learngrad-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file learngrad-0.1.0.tar.gz.

File metadata

  • Download URL: learngrad-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for learngrad-0.1.0.tar.gz
Algorithm Hash digest
SHA256 592451306b73be74c7833bf709fef076cf3785b1d129c64643f841869370e980
MD5 00586546ff18cdd5cd64fad46f7dc552
BLAKE2b-256 7f0a35728e9a06f11ad8eac53d249997af83237e5cedb95cdd1ee305375a0379

See more details on using hashes here.

File details

Details for the file learngrad-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: learngrad-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for learngrad-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c66d0e520bc8e300c0e4dcb63922b416cc3470de4790ffe8d52781061ec2f387
MD5 91ff958dc557cbe1e556aa50ad2b9a7a
BLAKE2b-256 85c47e0fcea031767423112abbe733b3ba86fa3da7cce35c11d422abccba66c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page