Take it slow, compute gradients
Project description
slowgrad
A small neural network library optimized for learning.
Inspired by PyTorch, micrograd, and tinygrad.
Build an MNIST Convnet
from slowgrad.layers import Linear, Conv2d
class TinyConvNetLayer:
def __init__(self):
self.c1 = Conv2d(1,8,kernel_size=(3,3))
self.c2 = Conv2d(8,16,kernel_size=(3,3))
self.l1 = Linear(16*5*5,10)
def parameters(self):
return [*self.l1.get_parameters(), *self.c1.get_parameters(), *self.c2.get_parameters()]
def forward(self, x):
x = x.reshape(shape=(-1, 1, 28, 28))
x = self.c1(x).relu().max_pool2d()
x = self.c2(x).relu().max_pool2d()
x = x.reshape(shape=[x.shape[0], -1])
return self.l1(x).logsoftmax()
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
slowgrad-0.1.0.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file slowgrad-0.1.0.tar.gz
.
File metadata
- Download URL: slowgrad-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cab95e93de813346e313ca02c6ed51f4adb15227081dff5b18818fa00c3d913 |
|
MD5 | dab46f05f4bd16d7361aed420459c7a5 |
|
BLAKE2b-256 | 02a628c4ccb93ada5e50c5e0c7907402a740e66443c9ba2f09147cd428f82270 |
File details
Details for the file slowgrad-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: slowgrad-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d0c2608ee638abc50940222faf14a243ce6156a9e2b5f326556378587b20815 |
|
MD5 | 206624a925df67a47b6b365024132d97 |
|
BLAKE2b-256 | 4dc20a613dce44b54577c273f618c80babef3fddbbbd694c37428d17cfcb3da2 |