Skip to main content

Mini deep learning framework

Project description

Kiwigrad


Maintenance

Despite lacking the ability to fly through the skies like PyTorch and TensorFlow, the Kiwigrad is still a formidable bird that is teeming with untapped potential waiting to be uncovered. :wink:

Kiwigrad? yes, it is another version of micrograd that was created just for fun and experimentation.

Install

To install the current release,

pip install kiwigrad

Functionalities

Kiwigrad is a modified version of the micrograd and the minigrad packages with additional features. The main features added to Kiwigrad are:

  • Training is faster due to the C implementation of the Value object.
  • Tracing functionalities like the original micrograd package were added. An example of this can be seen in the ops notebook.
  • Methods for saving and loading the weights of a trained model.
  • Support for RNN(1) feedforward neural networks.

Examples

  • In the examples folder, you can find examples of models trained using the Kiwigrad library.
  • A declaration example of an MLP net using Kiwigrad:
from kiwigrad import MLP, Layer

class PotNet(MLP):
    def __init__(self):
        layers = [
            Layer(nin=2, nout=16, bias=True, activation="relu"),
            Layer(nin=16, nout=16, bias=True, activation="relu"),
            Layer(nin=16, nout=1, bias=True, activation="linear")
        ]
        super().__init__(layers=layers)

model = PotNet()
  • Kiwigrad like micrograd and the minigrad comes with support for a number of possible operations:
from kiwigrad import Value, draw_dot

a = Value(-4.0)
b = Value(2.0)
c = a + b
d = a * b + b**3
c += c + Value(1.)
c += Value(1.) + c + (-a)
d += d * Value(2) + (b + a).relu()
d += Value(3.) * d + (b - a).relu()
e = c - d
f = e**2
g = f / Value(2.0)
g += Value(10.0) / f
print(f'{g.data:.4f}') # prints 24.7041, the outcome of this forward pass
g.backward()
print(f'{a.grad:.4f}') # prints 138.8338, i.e. the numerical value of dg/da
print(f'{b.grad:.4f}') # prints 645.5773, i.e. the numerical value of dg/db

draw_dot(g)

Todos

  • Include the activation functions tanh in the Value object.

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

kiwigrad-0.27.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

kiwigrad-0.27-cp39-cp39-macosx_10_9_universal2.whl (17.3 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file kiwigrad-0.27.tar.gz.

File metadata

  • Download URL: kiwigrad-0.27.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for kiwigrad-0.27.tar.gz
Algorithm Hash digest
SHA256 604c7729bbbf2a9f5de3e152ad6af9382d86e2a986aac0c8dce33fa7bc34de8b
MD5 2e9d68bfcd2019c6bfdab1d45739d7dd
BLAKE2b-256 b60aa49c915295f4a1e0fd4f1190212d120b453187e31d7972cd7fcf8cc8d74f

See more details on using hashes here.

File details

Details for the file kiwigrad-0.27-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for kiwigrad-0.27-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a67e97c915beda13e4ceea13f9214ce3be55f35335f4c5f25f19f78e5995c47f
MD5 3a180892fd2cbdab6dc3704f7c61f36c
BLAKE2b-256 daa8548413778ef448a2156d336e15b00be40556470d37bcc9f3de8fad611c28

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