Skip to main content

micrograd with added documentations using nbdev

Project description

micrograd2023

Introduction

How to install

The micrograd2023 package was uploaded to PyPI and can be easily installed using the below command.

pip install micrograd2023

Developer install

If you want to develop micrograd2023 yourself, please use an editable installation.

git clone https://github.com/hdocmsu/micrograd2023.git

pip install -e "micrograd2023[dev]"

You also need to use an editable installation of nbdev, fastcore, and execnb.

Happy Coding!!!

How to use

Here are examples of using micrograd2023.

# import necessary objects and functions
from micrograd2023.engine import Value
from micrograd2023.nn import Neuron, Layer, MLP
from micrograd2023.utils import draw_dot
import random
# inputs xs, weights ws, and bias b
w1 = Value(1.1)
x1 = Value(0.5)
w2 = Value(0.12)
x2 = Value(1.7)
b = Value(0.34)

# pre-activation
s = w1*x1 + x2*w2 + b

# activation
y = s.tanh()

# automatic differentiation
y.backward()

# show the computation graph of the perceptron
draw_dot(y)

# added random seed for reproducibility
random.seed(1234)
n = Neuron(3)
x = [Value(0.15), Value(-0.21), Value(-0.91) ]
y = n(x)
y.backward()
draw_dot(y)

You can use micrograd2023 to train a MLP and learn fundamental concepts such as overfilling, optimal learning rate, etc.

Good training

Overfitting

Testings

To perform unit testing, using terminal to navigate to the directory, which contains tests folder, then simply type python -m pytest on the terminal. Note that, PyTorch is needed for the test to run since derivatives calculated using micrograd2023 are compared against those calculated using PyTorch as references.

python -m pytest

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

micrograd2023-0.0.2.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

micrograd2023-0.0.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file micrograd2023-0.0.2.tar.gz.

File metadata

  • Download URL: micrograd2023-0.0.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.8.0 tqdm/4.64.1 CPython/3.8.12

File hashes

Hashes for micrograd2023-0.0.2.tar.gz
Algorithm Hash digest
SHA256 343cdae63245ffb97337f12b8e35e4fb3fe39c6db51801bc27f5195a2b69c6d0
MD5 f3616f8470895267248107e48ea8dc41
BLAKE2b-256 cb2ca06b9de779c00b7a93dd91359972803ef09b6e6cbcb4536b1367303afcca

See more details on using hashes here.

File details

Details for the file micrograd2023-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: micrograd2023-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.8.0 tqdm/4.64.1 CPython/3.8.12

File hashes

Hashes for micrograd2023-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 306e4cff816fec0013a1a6bd9d45e1e0e5d6989b438d575d3e84c975e7654bf0
MD5 c7352ea1cfe453b02a9d7fa084d30a50
BLAKE2b-256 1085e87be748d15abae3f3e5a296c9743043462d92434807231b30ad31b98219

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