Skip to main content

micrograd with added documentations using nbdev

Project description

micrograd2023

Introduction

I have done several projects

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: micrograd2023-0.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 9f1d293c5005878bc46bc99c768ff7187fcc4ff981ef81a8f2017208d84d26db
MD5 2b8c345820f4f7c7b5ef240ac1c1e72f
BLAKE2b-256 50baa620dc4b9f45d245681c0deaa669df382b759c06bdafe3b7fa26a707d20f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: micrograd2023-0.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e228d65229cd32873b2f9cb502284cb92ecf9b38a36ebdf49d993144806850d5
MD5 e6f7ee98c55f3fc6de86dd52818ad276
BLAKE2b-256 b0f66366a4c90b237667fe8b134d51b62038d1bd46237c53c9e342e5ad79f857

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