Layers¤
Every layer subclasses Module. Activations are also available as plain
functions under minitorch.functional (aliased as F).
Linear¤
Linear
¤
Bases: Module
Fully-connected layer y = x @ W + b.
Weights use Kaiming init by default (init='xavier' for glorot). Accepts any
input shape ending in in_features.
Source code in minitorch/layers.py
Activations¤
ReLU
¤
GELU
¤
Sigmoid
¤
Tanh
¤
Softmax
¤
Normalization and regularization¤
BatchNorm1d
¤
Bases: Module
Normalize a (batch, features) input per feature, with learnable scale/shift.
Tracks running mean and variance for use at eval time.
Source code in minitorch/layers.py
LayerNorm
¤
Bases: Module
Normalize over the last dimension. Works on any (..., num_features) input.
Source code in minitorch/layers.py
Dropout
¤
Embedding¤
Embedding
¤
Convolution¤
Conv2d
¤
Bases: Module
2D convolution over (N, C, H, W) input, implemented with im2col.
Source code in minitorch/conv.py
MaxPool2d
¤
Bases: Module
Max pooling over (N, C, H, W) input using strided windows.
Source code in minitorch/conv.py
Flatten
¤
Functional¤
functional
¤
relu
¤
Rectified linear unit, max(0, x).
Source code in minitorch/functional.py
gelu
¤
Gaussian error linear unit (tanh approximation, as in GPT-2).
Source code in minitorch/functional.py
sigmoid
¤
Logistic sigmoid, 1 / (1 + e**-x).
Source code in minitorch/functional.py
tanh
¤
Hyperbolic tangent.
Source code in minitorch/functional.py
softmax
¤
Softmax over axis. Numerically stable via max-subtraction.
Source code in minitorch/functional.py
log_softmax
¤
Log of softmax over axis. More stable than softmax(x).log().