"What I cannot create, I do not understand." -- Richard Feynman
I agree.
Clean code implementation of the foundational deep learning layers, optimizers and models
- using PyTorch's autograd for the backpropagation
- using PyTorch's tensors for GPU computation
lib.layers
|
Linear Embedding BatchNorm 1 BatchNorm1d BatchNorm2d LayerNorm 2 RMSNorm 3 LocalResponseNorm 4 Dropout 5 RNN_cell LSTM_cell 6 GRU_cell RNN Conv2d ConvTranspose2d |
Conv2dGroups Pool2d MaxPool2d AvgPool2d BatchAddPool SEGate 7 Graph_cell GCN_cell 8 GraphSAGE_cell 9 DiffPool 10 ReLU GELU 11 GLU 12 SwiGLU 13 |
Flatten DotProductAttention AdditiveAttention 14 DiagBlockAttention 15 ColumnBlockAttention 15 MultiHeadAttention 16 GroupedQueryAttention 17 RelativeWindowAttention SparseMultiHeadAttention 15 KVCache PositionalEncoding 16 RotaryEncoding 18 PatchEmbedding 19 RelativePositionBias2d 20 |
lib.autoencoders
|
MatrixFactorization |
AutoencoderLinear |
Word2Vec 21 |
lib.optimizers
|
Optimizer SGD SGD_Momentum AdaGrad |
RMSProp AdaDelta Adam AdamW 22 |
LR_Scheduler LR_StepScheduler LR_PlateauScheduler LR_CosineDecayScheduler |
lib.regularizers
|
L2_regularizer L1_regularizer |
elastic_regularizer max_norm_constraint_ |
grad_clip_ grad_clip_norm_ |
| Family | Models |
|---|---|
models.shallow_models
|
Perceptron, SVM, LeastSquareRegression, LogisticRegression, MulticlassPerceptron, MulticlassSVM, MultinomialLogisticRegression |
models.energy_based_models
|
HopfieldNetwork, HopfieldNetworkOptimized, RestrictedBoltzmannMachine |
models.recurrent_networks
|
RNN_factory, SimpleRNN, LSTM 6, GRU, LangModel, EchoStateNetwork, Encoder, Decoder, Seq2Seq 23 |
models.convolutional_networks
|
SimpleCNN, SimpleFullyCNN, LeNet5 24, AlexNet 4, NetworkInNetwork 25, VGG16 26, GoogLeNet 27, DeepPlainCNN |
models.residual_networks
|
ResNet34 28, ResNet50 28, ResNeXt50 29, SEResNet50 30, SEResNeXt50 30, DenseNet121 31, UNet_DDPM |
models.blocks.convolutional_blocks
|
Inception 27, ResBlock 28, ResBottleneckBlock 28, ResNeXtBlock 29, DenseLayer 31, DenseBlock 31, DenseTransition 31 |
models.graph_networks
|
GCN 8, GraphSAGE 9, GIN 32, DiffPoolNet 10 |
models.attention_networks
|
RecurrentAttention 33, SpatialTransformer 34, SpatialTransformerNet, AttentionEncoder 14, AttentionDecoder 14, BahdanauAttention 14 |
models.transformer_networks
|
TransformerEncoderLayer, TransformerEncoder, TransformerDecoderLayer, TransformerDecoder, Transformer 16, GPT_TransformerBlock 35, GPT_SparseTransformerBlock 15, GPT2 35, GPT3 36, LLaMA_TransformerBlock 37, LLaMA1 37, LLaMA2 38, LLaMA3 39 |
models.visual_transformers
|
VisionTransformer 19, VisionTransformerConvStem 40, SwinTransformerBlock 20, SwinTransformer 20 |
models.diffusion_models
|
DenoiseDiffusion 41 |
examples/shallow
|
Binary classification Multi-class classification Matrix factorization MNIST classification Visualize optimizers |
|
examples/energy_based
|
Memorize patterns with Hopfield Memorize more - optimized Hopfield Memorize with RBM |
|
examples/recurrent
|
Predict next character Predict masked words Translate English to French word2vec embeddings |
|
examples/convolutional
|
Image classification Feature maps visualization Saliency maps visualization |
|
examples/graph
|
Classify nodes in a graph Classify protein graphs |
|
examples/attention
|
Recurrent visual attention Translate with additive attention |
|
examples/transformers
|
Translate with Transformer Predict next token (byte-pair) Reproduce GPT-2 performance |
|
examples/diffusion
|
Generate colored digits |
|
- Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift
- Layer Normalization
- Root Mean Square Layer Normalization
- ImageNet Classification with Deep Convolutional Neural Networks
- Dropout: A Simple Way to Prevent Neural Networks from Overfitting
- Generating Sequences With Recurrent Neural Networks
- Squeeze-and-Excitation Gate layer
- Semi-Supervised Classification with Graph Convolutional Networks
- Inductive Representation Learning on Large Graphs
- Hierarchical Graph Representation Learning with Differentiable Pooling
- Gaussian Error Linear Units (GELUs)
- Language Modeling with Gated Convolutional Networks
- GLU Variants Improve Transformer
- Neural Machine Translation by Jointly Learning to Align and Translate
- Generating Long Sequences with Sparse Transformers
- Attention Is All You Need
- GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints
- RoFormer: Enhanced Transformer with Rotary Position Embedding
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Efficient Estimation of Word Representations in Vector Space
- Decoupled Weight Decay Regularization
- Sequence to Sequence Learning with Neural Networks
- Gradient-based learning applied to document recognition
- Network In Network
- Very Deep Convolutional Networks for Large-Scale Image Recognition
- Going deeper with convolutions
- Deep Residual Learning for Image Recognition
- Aggregated Residual Transformations for Deep Neural Networks
- Squeeze-and-Excitation Networks
- Densely Connected Convolutional Networks
- How Powerful are Graph Neural Networks?
- Recurrent Models of Visual Attention
- Spatial Transformer Networks
- Language Models are Unsupervised Multitask Learners
- Language Models are Few-Shot Learners
- LLaMA: Open and Efficient Foundation Language Models
- Llama 2: Open Foundation and Fine-Tuned Chat Models
- The Llama 3 Herd of Models
- Early Convolutions Help Transformers See Better
- Denoising Diffusion Probabilistic Models
uv sync
# Load the env
source .venv/Scripts/activate
# List all examples
find examples/ -name "*.py" -printf "python -m %p\n" | sed 's|/|.|g; s|\.py$||'
# Run an example:
python -m examples.attention.affine_mnist_spatial_transformer
MPLBACKEND=Agg pytest ./test
























