Skip to main content

A lightweight PyTorch-like autograd library built from scratch

Project description

SimpleGrad

SimpleGrad is a lightweight Python library for automatic differentiation and neural networks.
It is inspired by PyTorch and Tinygrad, offering a balance between simplicity, flexibility, and educational value.


Features

  • Tensor operations: +, -, *, /, @ (matmul), pow, exp, log, ln, sin, cos, tanh, relu, sigmoid.
  • Automatic differentiation: .backward() computes gradients for all operations in the computation graph.
  • Neural networks: Build networks using Linear layers and activation functions.
  • Loss functions: MSE, MAE, etc. (can be extended).
  • Gradient descent: Manual update or custom optimizers can be implemented.
  • Minimal and educational: Perfect for learning how autograd works under the hood.

from simplegrad import Tensor

# --------------------------
# Tensor operations
# --------------------------
a = Tensor([[1, 2, 3]], requires_grad=True)
b = Tensor([[2, 1, 0]], requires_grad=True)
c = a + b
d = a * b
e = d.sum()

print("c:", c)
print("d:", d)
print("e:", e)

# Backward pass
e.backward()
print("grad a:", a.grad)
print("grad b:", b.grad)

Installation

Clone the repository and install in editable mode:

pip install simplegrade

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

simplegrade-0.1.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

simplegrade-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file simplegrade-0.1.2.tar.gz.

File metadata

  • Download URL: simplegrade-0.1.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for simplegrade-0.1.2.tar.gz
Algorithm Hash digest
SHA256 25d790ff04e728a750d590f87ee05d582880b0f85e60c810b54e4718ab079585
MD5 b98d1c0defc87843d1c63865897c8e49
BLAKE2b-256 bb84b2c1d43c2dc841d7778d449a20268362b551ba284300da1bb1e8fee09d58

See more details on using hashes here.

File details

Details for the file simplegrade-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: simplegrade-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for simplegrade-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85e7aa716548d04c478ac0b545613804b2d851e58e07490dc95416045f0652b9
MD5 a94d6e579d43e294d875e50f46c1ba14
BLAKE2b-256 9e664dff6484dbb2cc054314c1d5d578a4e91e993d7b1f35faefe03c68f78459

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