A small PyTorch-like autograd engine and neural network library.
Project description
Tardigrad
A small PyTorch-like autograd engine and neural network library.
"As far as we tardigrades are concerned, Pluto is and always will be a planet. End of discussion."
― Zeno Alexander, The Library of Ever
Features
- Automatic differentiation for scalar (
Value) and tensor (Tensor) operations - Neural network layers (
Linear,Sequential) - SGD optimizer with gradient zeroing
- Lightweight with minimal dependencies (NumPy, SciPy)
Quick Start
Scalar Autograd
from tardigrad.value import Value
a = Value(2.0, label='a')
b = Value(3.0, label='b')
c = a * b + Value(1.0)
c.backward()
print(c.data) # 7.0
print(a.grad) # 3.0
print(b.grad) # 2.0
Tensor Operations
from tardigrad.tensor import Tensor
x = Tensor([[1, 2], [3, 4]])
y = Tensor([[5, 6], [7, 8]])
z = x.matmul(y)
z.backward()
print(z.data)
print(x.grad)
Neural Network
from tardigrad.layers import Linear, Sequential
from tardigrad.tensor import Tensor
from tardigrad.optim import SGD
model = Sequential([
Linear(2, 3),
Linear(3, 1)
])
optimizer = SGD(model.get_params(), alpha=0.01)
# Training loop
for epoch in range(10):
y_pred = model.forward(x_train)
loss = ((y_pred - y_train) ** 2).sum()
loss.backward()
optimizer.step()
Project Structure
tardigrad/
├── value.py # Scalar autograd engine
├── tensor.py # Multi-dimensional tensor autograd
├── layers.py # Neural network layers (Linear, Sequential)
└── optim.py # SGD optimizer
References
- micrograd by Andrej Karpathy
- Grokking Deep Learning by Andrew Trask
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
tardigrad-0.1.0.tar.gz
(2.9 MB
view details)
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 tardigrad-0.1.0.tar.gz.
File metadata
- Download URL: tardigrad-0.1.0.tar.gz
- Upload date:
- Size: 2.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79673c21a5f52f1f530f1d9c3446a90aa59a9d8ae1c1a4afe6101d3cf8253328
|
|
| MD5 |
db55b9d95da7e60825ef0c590e65cd24
|
|
| BLAKE2b-256 |
7728c504061212f1b2af24b0f9f6ed6d3d1509d1c4a3c422de3056cfc5943e3e
|
File details
Details for the file tardigrad-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tardigrad-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0edbc7918bb3039fad8754c048da71fda2448a85bfbbf6700631d0d241751ab9
|
|
| MD5 |
dad86667725d56dfa94820ecfb6f10ba
|
|
| BLAKE2b-256 |
73ab4d63f5840dd769d569d6d79be319fc6e3e2f4769180f1e56bdf8106d8ebd
|