Skip to main content

Take it slow, compute gradients

Project description

slowgrad

Unit tests

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


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.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

slowgrad-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file slowgrad-0.1.1.tar.gz.

File metadata

  • Download URL: slowgrad-0.1.1.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

Hashes for slowgrad-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fe4db1b600889c4ae966adb87c331cf5de462a53256ec96a92ce5f599f32944c
MD5 492c596a7de6c3a748e67988e8394836
BLAKE2b-256 1c11619680d629984b06068266f22831f89e1f604b1d334d37b755f872d07dad

See more details on using hashes here.

File details

Details for the file slowgrad-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: slowgrad-0.1.1-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

Hashes for slowgrad-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64e4902030ce703aae3284b103cc1e63de84203b270b7f7f7630578b51a51933
MD5 b5c2a76f23ad7e5e4692afdd3b64b19c
BLAKE2b-256 d8645380a03f1b8b1fd18eeaa195f33798a7080e157cffe77282543c1e0002d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page