🏠 Home ⚡ Features 📚 API Reference 💡 Examples 📦 Installation 📋 Changelog
⚡ Framework Features

Everything You Need to Build & Deploy

A complete deep learning toolkit — from tensors and autograd to pre-built models and system monitoring — all in one lightweight package.

Automatic Differentiation

Reverse-mode autograd engine that supports full broadcasting, tuple-axis reductions, and gradient accumulation — the backbone of every model.

🧮

Tensor with Autograd

Every Tensor tracks its computation history. Call .backward() to flow gradients back through the entire graph automatically.

requires_grad backward() grad detach()
📐

Broadcasting Support

Full NumPy-compatible broadcasting in all forward and backward passes. Handles complex shapes including tuple-axis reductions needed for CNN global pooling.

Broadcasting Tuple Axis CNN Pooling
New in v2.1: no_grad and enable_grad context managers — disable autograd during inference. Also works as a decorator. The Trainer now uses no_grad automatically during validation for memory efficiency.

Layers & Activations

All layers subclass lm.Module. Mix and match in Sequential or build custom modules.

Linear

Fully-connected layer with configurable input/output features and optional bias.

in_featuresout_featuresbias
🔲

Conv2d

2D convolution with im2col-based backward pass. Supports padding, stride, and multi-channel inputs.

kernel_sizestridepadding
📏

BatchNorm1d / 2d

Normalizes activations per batch. Supports learnable gamma/beta, running stats, and train/eval modes.

Running StatsTrain/Eval
🔽

MaxPool2d / AvgPool2d

Spatial pooling layers that reduce feature map dimensions. Configurable kernel and stride.

MaxPoolAvgPool
💧

Dropout

Randomly zeroes elements during training. Automatically disabled in eval mode via model.eval().

p=0.5Auto Eval
📝

Embedding

Learnable lookup table for integer indices. Ideal for NLP tasks and categorical features.

num_embeddingsembedding_dim
🔁

LSTM New v2.1

Long Short-Term Memory layer with single-cell and multi-step variants, multi-layer support, and dropout.

Multi-layerDropout
🔄

GRU New v2.1

Gated Recurrent Unit — lighter than LSTM with comparable performance for many sequence tasks.

GatedRecurrent

Flatten

Reshapes feature maps to 1D vectors. Configurable start_dim for flexible CNN-to-FC transitions.

start_dim=1

Activation Functions

ReLU
max(0, x)
LeakyReLU
x if x>0 else αx
ELU
Smooth negative region
GELU
Gaussian error linear
Sigmoid
1/(1+e^-x)
Tanh
(e^x-e^-x)/(e^x+e^-x)
Softmax
Probability distribution
LogSoftmax
log(softmax(x))

Optimizers & LR Schedulers

Optimizers

SGD
SGD + Nesterov
Momentum, weight decay, Nesterov acceleration
Adam
Adam + AMSGrad
Adaptive moment estimation with optional AMSGrad
AdW
AdamW
Adam with decoupled weight decay — preferred for regularization
RMS
RMSprop
Root mean square propagation with momentum
AdG
AdaGrad
Adaptive gradient algorithm for sparse features
New in v2.1: All optimizers support parameter groups — set different LR/weight-decay per layer group, just like PyTorch.

LR Schedulers

StepLR
Decay by gamma every N epochs
MultiStepLR
Decay at specific milestone epochs
CosineAnnealingLR
Smooth cosine decay to eta_min
ReduceLROnPlateau
Reduce when metric stops improving
ExponentialLR
Exponential decay every epoch
LinearWarmupLR
Linear warmup over N steps
CyclicLR
Cyclic LR between base and max (per batch)

Metrics & Monitoring

Classification Metrics

FunctionDescription
accuracy()Top-1 accuracy, 0–1 float
top_k_accuracy()Top-k accuracy (e.g. top-5)
precision()Macro/micro/per-class precision
recall()Macro/micro/per-class recall
f1_score()Macro/micro/per-class F1
confusion_matrix()(C, C) numpy array

Regression Metrics

FunctionDescription
r2_score()R² coefficient of determination
mean_squared_error()MSE between predictions and targets
mean_absolute_error()MAE — outlier-robust error metric

System Monitoring

📡

SystemMonitor

Track CPU usage, RAM, temperature and health score on Raspberry Pi in real time. Use memory_trace context to find bottlenecks, and ModelProfiler to measure FLOPs and throughput.

health_score() memory_trace ModelProfiler

Trainer & Callbacks

Skip the boilerplate. The Trainer handles training loops, validation, logging, and callbacks automatically.

lm.Trainer

Auto Training Loop
Handles epoch, batch, forward, backward, step
Validation Support
Automatic validation after each epoch with no_grad
Gradient Clipping
clip_grad parameter to prevent exploding gradients
Gradient Accumulation New
Simulate large batches on Pi with grad_accum_steps
Predict & Evaluate
trainer.predict(), predict_proba(), evaluate()

Built-in Callbacks

⏹️

EarlyStopping

Stop training when a metric stops improving. Configure patience, min_delta, and mode (min/max).

💾

ModelCheckpoint

Automatically save the best model weights to disk during training. Monitors any metric.

📉

LRSchedulerCallback

Integrate any LR scheduler into the Trainer callback system seamlessly.

📊

History

Record all training metrics per epoch. Access via history['train_loss'] for plotting.

Pre-built Models

🧠

MicroMLP

Multi-layer perceptron for tabular and flat data. Configurable hidden layer sizes with built-in Dropout regularization.

Tabular DataCustomizable
🖼️

MicroCNN

Lightweight CNN optimized for small images (32×32). Supports RGB and grayscale inputs with configurable num_classes.

Image ClassificationSmall Images
🔗

TinyResNet

ResNet with residual connections for better gradient flow. Reduce base_filters to 8 for very constrained devices.

Residual ConnectionsConfigurable

Weight Initialization

xavier_uniform_

Uniform distribution scaled by fan-in and fan-out. Ideal for tanh/sigmoid layers.

xavier_normal_

Normal distribution variant of Xavier initialization.

kaiming_uniform_

He initialization for ReLU networks — accounts for the non-linearity.

kaiming_normal_

Normal Kaiming init — works well for deep ReLU networks.

orthogonal_

Orthogonal matrix init. Preserves gradient norms in deep networks.

init_module()

Apply initialization to a whole module recursively with one call.