Metadata-Version: 2.4
Name: micrograd-rust
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Summary: A Rust-backed scalar autograd engine. Drop-in replacement for Karpathy's micrograd, but 13-75x faster.
Keywords: autograd,neural-network,backpropagation,micrograd,rust
Author: Kia Ghods
License-Expression: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/kiaghods/micrograd-rust

# micrograd-rust

A Rust-backed scalar autograd engine and neural network library for Python. Drop-in replacement for [Karpathy's micrograd](https://github.com/karpathy/micrograd), but 13-75x faster.

## Install

```bash
pip install micrograd-rust
```

## Usage

```python
from micrograd_rust import Value, MLP

# scalar autograd
a = Value(2.0)
b = Value(3.0)
c = (a * b + a).tanh()
c.backward()
print(a.grad)  # dc/da
print(b.grad)  # dc/db

# neural network
mlp = MLP(3, [4, 4, 1])
x = [Value(1.0), Value(2.0), Value(3.0)]
out = mlp(x)
out[0].backward()
```

## API

### `Value(data, label="")`
- `.data` — the scalar value
- `.grad` — the gradient (populated after `.backward()`)
- Supports `+`, `*`, `**`, `-`, `/`, `.tanh()`, `.exp()`, `.backward()`

### `MLP(nin, nouts)`
- `mlp(x)` / `mlp.forward(x)` — forward pass, returns list of `Value`
- `mlp.parameters()` — list of all `Value` parameters
- `mlp.zero_grad()` — reset all gradients to 0

## How it works

Uses [PyO3](https://pyo3.rs) to call into a Rust autograd engine under the hood. All computation happens in Rust. See the [GitHub repo](https://github.com/kiaghods/micrograd-rust) for benchmarks and source.

