Skip to content

Getting Started

Installation

MiniTorchBR is available on PyPI and requires Python 3.10+. Release wheels target Linux x86-64, Windows x64, and 64-bit Intel/Apple silicon macOS.

pip install minitorchbr

Or install from source:

git clone https://github.com/BriceLucifer/MiniTorch.git
cd MiniTorch
uv venv
uv sync

Source installation compiles the optional native training extension and therefore requires a C/C++ build toolchain.

Dependencies

Package Purpose
numpy ≥ 1.24 Tensor computation
matplotlib ≥ 3.7 Training plots
pyvis ≥ 0.3 Interactive graph rendering

Project Layout

MiniTorch/
├── core/       # Variable (tensor) + Function (op base)
├── ops/        # 20+ differentiable operations
├── nn/         # Module, Linear, Sequential
├── optim/      # SGD, Adam
├── native/     # Compiled dense-classifier training
├── visualization/ # Interactive model explorer
├── data/       # MNIST loader, DataLoader
└── utils/      # Graph viz, training viz, numerical diff

Your First Computation

import numpy as np
from MiniTorch.core.variable import Variable

# Scalars
a = Variable(np.array(2.0))
b = Variable(np.array(3.0))

c = a * b + a   # c = a*b + a  →  dc/da = b+1 = 4,  dc/db = a = 2
c.backward()

print(a.grad.data)   # 4.0
print(b.grad.data)   # 2.0

Disabling Gradient Tracking

Use no_grad for inference to save memory and speed up computation:

from MiniTorch.core.config import no_grad

with no_grad():
    out = model(x)   # no graph is built

Next Steps