Skip to main content

A small autograd engine + neural network + visualization library

Project description

BITGRAD: A small autograd engine + neural network + visualization library Bitgrad is a minimal neural network built from scratch in Python

Key Features:

Value Class with reverse-mode autodiff Neurons, Layers and MLPs Graph Visualization (SVG) Structured project files and directories + packaging

INSTALLATION

Install from PyPI:

pip install bitgrad

Or install from source:

git clone https://github.com/falloficarus22/bitgrad
cd bitgrad
pip install -e .

Example Usage:

from bitgrad import MLP, Value

# A simple 2 → 4 → 4 → 1 network
model = MLP(2, [4, 4, 1])

xs = [[2.0, 3.0], [1.0, -1.0], [-3.0, 0.5]]
ys = [1.0, -1.0, 1.0]

for k in range(200):
    ypred = [model(x)[0] for x in xs]
    loss = sum((yp - y)**2 for yp, y in zip(ypred, ys))

    # zero grads
    for p in model.parameters():
        p.grad = 0.0
    
    # backprop
    loss.backward()

    # SGD update
    for p in model.parameters():
        p.data -= 0.05 * p.grad

print("Final loss:", loss.data)

GRAPH VISUALIZATION

Bitgrad includes computational graph visualizer usin Graphviz

Saving a graph:

from bitgrad.viz import save_graph

save_graph(loss, "loss.pkl")

Rendering it:

bitgrad viz --file loss.pkl
bitgrad viz -f loss.pkl

COMMAND LINE INTERFACE

Bitgrad installs a CLI called bitgrad

XOR Demo:

bitgrad xor

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

bitgrad-0.1.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitgrad-0.1.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file bitgrad-0.1.2.tar.gz.

File metadata

  • Download URL: bitgrad-0.1.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for bitgrad-0.1.2.tar.gz
Algorithm Hash digest
SHA256 234933de6260732bdc0298e9ffd89eeb9ed146401a56961042ff542bd0440028
MD5 7568a976bf86a9401e2eaa8a07e5aa42
BLAKE2b-256 5a457946c7332121db981df665324b11ca84dc275b89f159e41e3d7cc5d45f0b

See more details on using hashes here.

File details

Details for the file bitgrad-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: bitgrad-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for bitgrad-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ceb9a1c8d1ab1f543836ec82fd64dbd7c8c41daaf048ce31e005707babbc4e55
MD5 8fe01bbed40d8b59fbf5905cc5b83b72
BLAKE2b-256 19f3d48ce6bde7c211fd772a67bf7b35f0bbc74187f956eefa11301c0bd2977d

See more details on using hashes here.

Supported by

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