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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
992f9011060cfaf48c87a4a6654d397b693e3a8b23f6ac550acfda045274e73d
|
|
| MD5 |
6f3b0facbf3e0e925df6405b657c82a2
|
|
| BLAKE2b-256 |
4072a2a8562280e604097c37f9809b6fc9f7e3d968d4c4e1c81e249936a40cae
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21d780b1f3d520617b192aaa233d34e2a937b01fba721765e526bea4c19655c
|
|
| MD5 |
d8f174739687b3df1e21f333f2e61cb9
|
|
| BLAKE2b-256 |
f60c5ea7e9eaa722ae9c3f32702dda27c51eb67cc416d95700077ba14ab28e8c
|