Skip to main content

A tiny educational autograd library.

Project description

hobbitgrad

hobbitgrad is a tiny educational autograd library written in pure Python. It includes a small NDArray, a Tensor type with backpropagation, a linear layer, SGD, and mean squared error loss.

Install

pip install hobbitgrad

Example

from hobbitgrad import Linear, SGD, Tensor, mse

x = Tensor([[0, 0], [0, 1], [1, 0], [1, 1]])
y = Tensor([[0], [0], [0], [1]])

model = Linear(2, 1)
optimizer = SGD(model.parameters(), lr=0.1)

for _ in range(100):
    pred = model.forward(x)
    loss = mse(pred, y)
    loss.backward()
    optimizer.step()
    optimizer.zero_grad()

print(loss.data.data[0])

Current Scope

hobbitgrad currently supports a small set of tensor operations, broadcasting, matrix multiplication, scalar reductions, a linear layer, SGD, and MSE loss.

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

hobbitgrad-0.0.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

hobbitgrad-0.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file hobbitgrad-0.0.2.tar.gz.

File metadata

  • Download URL: hobbitgrad-0.0.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hobbitgrad-0.0.2.tar.gz
Algorithm Hash digest
SHA256 fd966a4c12519080362f0b163406951f5025acb7d1028bc38b41d85ad454f41e
MD5 a492b4222a65d094de6569012f452a44
BLAKE2b-256 f5ffd7acc50ce3df6d4d7ff975cb5b180d85fb7ab4c2fa431671f4159c50e3cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for hobbitgrad-0.0.2.tar.gz:

Publisher: publish.yml on creasac/hobbitgrad

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hobbitgrad-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: hobbitgrad-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hobbitgrad-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 480650b49aeffefc39767164e1dff8ba1b3bf75b80a536bcbf21a633d5b5f1d7
MD5 0b13e3c54452b6760cc53fe163fc43ec
BLAKE2b-256 982bc96efc5265b11d13012a69d797a4dfa0f8b6d9a867edd12966659e265369

See more details on using hashes here.

Provenance

The following attestation bundles were made for hobbitgrad-0.0.2-py3-none-any.whl:

Publisher: publish.yml on creasac/hobbitgrad

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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