FIT: Machine Learning Library

A PyTorch-like machine learning library built from scratch with NumPy. Train neural networks with automatic differentiation, no dependencies beyond NumPy.

Tests License

Quick Start

Install FIT:

pip install git+https://github.com/Klus3kk/fit.git

Solve XOR problem:

from fit.core.tensor import Tensor
from fit.nn.modules.container import Sequential
from fit.nn.modules.linear import Linear
from fit.nn.modules.activation import ReLU
from fit.loss.regression import MSELoss
from fit.optim.adam import Adam

# XOR dataset
X = Tensor([[0, 0], [0, 1], [1, 0], [1, 1]])
y = Tensor([[0], [1], [1], [0]])

# Model
model = Sequential(
    Linear(2, 8),
    ReLU(),
    Linear(8, 1)
)

# Training
loss_fn = MSELoss()
optimizer = Adam(model.parameters(), lr=0.01)

for epoch in range(1000):
    pred = model(X)
    loss = loss_fn(pred, y)

    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

Why FIT?

  • Lightweight: Only requires NumPy

  • Educational: Understand ML from first principles

  • Familiar API: PyTorch-like interface

  • Production ready: Type hints, logging, proper error handling

Documentation

Indices and tables