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 simplegrade 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.3.tar.gz (6.8 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.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simplegrade-0.1.3.tar.gz
  • Upload date:
  • Size: 6.8 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.3.tar.gz
Algorithm Hash digest
SHA256 306879ab2012474e8ba1ed7a6a3e6cec7fd4c34e307c801d1a79dd4bb7a59e42
MD5 37434de6270178c75b3cb17dc4783681
BLAKE2b-256 b29caeb55eb2acd8579bedb9cc7cd14a051337dafcc4b6a8d3065ca3b90fcbae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simplegrade-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cfba39d5cf77e6cc6b4f9e05467a6a9e4158e9f901a2ed2cb2a22a7b222bffcd
MD5 9d2117a84af2b5e832a4f28aa08f8206
BLAKE2b-256 dcee27f9d91f6527dee22b52a5198fe0132a16066d1e34e44a6d0417c1330655

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