Backpropagation from scratch
Project description
smallgrad
smallgrad is a minimalistic engine that implements backpropagation from scratch for neural networks. It allows users to visualize the computational graph along with the gradients and includes a script for building a Multi-Layer Perceptron (MLP) and visualize its computational graph.
Features
- Backpropagation from Scratch: Implements a simple and understandable version of backpropagation, making it a great learning resource.
- Visualize Computational Graph: Visualizes the computational graph and gradients during the forward and backward pass.
- MLP Builder Script: Easily build Multi-Layer Perceptrons (MLPs) and visualize their learning process.
Installation
If you want the latest updates:
git clone https://github.com/lorenzo-delsignore/smallgrad.git
cd smallgrad
pip install -e .
If you want the stable version:
pip install smallgrad
To render the computational graph, you also need an external dependency Graphviz.
If you want to install the dependency with conda you use the following command: conda install -c conda-forge pygraphviz.
You can install smallgrad also with Docker, in which contains also the external Graphviz dependency:
cd smallgrad
docker -t smallgrad .
Usage
To use smallgrad, you can run the provided script to create an MLP and visualize the computational graph:
usage: smallgrad [-h] [--save_dir SAVE_DIR] --input INPUT [INPUT ...] --output OUTPUT [OUTPUT ...] [--activation ACTIVATION]
Options:
- save_dir: Directory to save the visualization of the computational graph.
- input: Specify the input features for the MLP.
- output: Specify the output dimensions of each hidden and output layer of the MLP.
- activation: Choose the activation function (only relu and tanh are supported at the moment) for the MLP layers.
Example Usage:
smallgrad --input 2 4 --output 3 1 --activation relu --save_dir ./graphs
With Docker:
docker run --rm --name smallgrad -v host_path_to_save:/graphs smallgrad --input 1 1 --output 2 1 --activation relu --save_dir /graphs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smallgrad-1.0.2.tar.gz.
File metadata
- Download URL: smallgrad-1.0.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00b24fa8d18a386d4f74e8d596074bad94d03fde1eea55909d1b5d1a85e0b1e4
|
|
| MD5 |
bb03503724caca190a8dd44c17d99f9a
|
|
| BLAKE2b-256 |
8c40daf2736e097d9639e87e1c3441717517a6e460b14e2ed45f937deb73f7dd
|
File details
Details for the file smallgrad-1.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: smallgrad-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cbf903a92f0014e0ede52d94b75838c75cf7ab17cdcad187ed2af48bdaeddaa
|
|
| MD5 |
6226ee0e9ef6c33e98dbb18b53dabedb
|
|
| BLAKE2b-256 |
95b5080816fb70f8857495150c2aaf522e6c68b4ba9805241459007e563f8d3e
|