Skip to main content

A minimal deep learning framework with automatic differentiation

Project description

minigrad

minigrad is a toy implementation of an autograd engine, inspired by Andrej Karpathy's micrograd project, with and API similar to that of PyTorch. It supports both CPU and GPU operations using NumPy and CuPy, respectively.

My goal with minigrad is to explore and learn the internals of deep learning frameworks — minigrad is not optimized for speed or efficiency. As of now it provides basic tensor operations, back propagation, neural network layers, optimizers, and loss functions.

Features

  • Tensor Operations: Supports basic tensor operations with automatic differentiation.
  • CPU and GPU Support: Use NumPy for CPU operations and CuPy for GPU operations.
  • Neural Networks: Includes simple layers like Linear and activations like ReLU
  • Optimizers: Implements basic optimizers like SGD.
  • Loss Functions: Provides loss functions like MSELoss.

Installation

Clone the repository and install minigrad:

git clone https://github.com/udaysankar01/minigrad.git
cd minigrad
pip install -e .

Usage

Basic Usage

import minigrad as mg

a = mg.Tensor([1, 2, 3], device='gpu')
b = mg.Tensor([2, 3, 4], device='gpu')
c = a + b
d = c.sum()
d.backward()
print(a.grad)
print(b.grad)

Training a Neural Network

  • A very simple example of training a neural network can be found in examples/simple_nn.py
  • TODO: Add more examples.

Run Tests

To run the unit tests and benchmarks for the project

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

minigrad_python-0.1.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

minigrad_python-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file minigrad_python-0.1.0.tar.gz.

File metadata

  • Download URL: minigrad_python-0.1.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for minigrad_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b3c0c132b35ffa0eaa6fa07c61500d1020705a0b5d53faa71a444594d8d163b4
MD5 6068d8cbb68175be6d23a5e58ea48e06
BLAKE2b-256 c5519454c4c74dab75e4e60b6f62ee21101c9abaa440ec5a8eb95e07820c5d42

See more details on using hashes here.

File details

Details for the file minigrad_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for minigrad_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9436bd95254141eaacef0cc86a7bd82af560b9ec4f9c80b2cc6a61442da6612
MD5 767b4302d63f6af295257f8adc4bf53e
BLAKE2b-256 b25e8ed4228e31b1bc9c7683aed69cc1c608ad1b7724c9d543194b43d6eb3ac5

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