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.1.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.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: learngrad-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 5ce7fc03ec68534af073dbf9889e15360218e727e3c9ea3dbf357935713a6f94
MD5 9458fe0842a748546979604af0f1b4d4
BLAKE2b-256 d25c527fa1c36fc394cb58a4787090989195ce4a6d4165219b127e19079de076

See more details on using hashes here.

File details

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

File metadata

  • Download URL: learngrad-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e26e3bf5650fa5049f8991ba4cee51b92c61c09056e1e01148ab9193ea6946f
MD5 2b35eea5ec33a27cb5d0a6199e603e43
BLAKE2b-256 8fab0d69035642a998d5929616192dd821bd2646b55a7c75684fbea0d0bb682b

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