Skip to main content

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)

Running test

cd test 
pytest .

Release files for kiwigrad 0.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kiwigrad 0.28
File Size Uploaded
kiwigrad-0.28.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kiwigrad 0.28
File Interpreter ABI Platform
kiwigrad-0.28-cp39-cp39-macosx_10_9_universal2.whl CPython 3.9 CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size: 27.9 kB

Release files / kiwigrad-0.28.tar.gz

Download URL kiwigrad-0.28.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fe118ec44b0a7f2b3573f8807481a182b7b390a9cc51284e8404523ee60d0332
BLAKE2b-256 checksum
How to use checksums
70cc26f79c4d09886377fda0ff4a1fd845b8013b168b0c0b9f1eceeb639155c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / kiwigrad-0.28-cp39-cp39-macosx_10_9_universal2.whl

Download URL kiwigrad-0.28-cp39-cp39-macosx_10_9_universal2.whl
Size 17.5 kB
Tags CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
73cca6c4fcc751bfa0ca7564159818ef62cea3951144be64a57d4a2bf77031fb
BLAKE2b-256 checksum
How to use checksums
5db4c6db648eeace5c080288102f92b765537d719a7ab5a4298457000506bc5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.28 This release

2 release files

0.27

2 release files

0.26

2 release files

0.25

2 release files

0.24

2 release files

0.23

2 release files

0.22

2 release files

0.21

2 release files

0.20

2 release files

0.19

2 release files

0.18

2 release files

0.17

2 release files

0.16

2 release files

0.15

2 release files

0.14

2 release files

0.13

2 release files

0.12

2 release files

0.11

2 release files

0.1

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page