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.

It is intended for learning how tensor operations and backpropagation fit together.

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.

The API is early and may change.

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.1.tar.gz (5.4 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.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hobbitgrad-0.0.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hobbitgrad-0.0.1.tar.gz
Algorithm Hash digest
SHA256 992f9011060cfaf48c87a4a6654d397b693e3a8b23f6ac550acfda045274e73d
MD5 6f3b0facbf3e0e925df6405b657c82a2
BLAKE2b-256 4072a2a8562280e604097c37f9809b6fc9f7e3d968d4c4e1c81e249936a40cae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hobbitgrad-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hobbitgrad-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b21d780b1f3d520617b192aaa233d34e2a937b01fba721765e526bea4c19655c
MD5 d8f174739687b3df1e21f333f2e61cb9
BLAKE2b-256 f60c5ea7e9eaa722ae9c3f32702dda27c51eb67cc416d95700077ba14ab28e8c

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