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.2.0.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file slowgrad-0.2.0.tar.gz
.
File metadata
- Download URL: slowgrad-0.2.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 | a661351c38becf3fc92775b93ef952d99825d674a0efdec37cf9474dcde88977 |
|
MD5 | 134d14d341226d3817d1a97152d33207 |
|
BLAKE2b-256 | b840da0f828c3995c1d77a94bf0018ec34fa0451e7c660fae5e6e8d1ed87159a |
File details
Details for the file slowgrad-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: slowgrad-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.3 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 | 42d793a133161badf03e5a9203e4ef15c560a7ad89c84ff64f3ccb5a2695a257 |
|
MD5 | c5ab77e4ac3b5d982f77a810dd10f995 |
|
BLAKE2b-256 | d91dd6b6a607604d4f0398effe7bc8d22971f490aa3de9492f13a987811cf83e |