Machine Learning from scratch in Odin.
This is a personal side project I work on Sundays only while pursuing my MSc in AI.
The goal:
- Learn ML internals by implementing algorithms from the ground up
- Explore Odin as a low-level systems language for numerical computing
- Document the journey for others who want to go beyond Python/NumPy
- Explore both supervised and unsupervised learning algorithms over time
- Vector type + basic ops (add, sub, scalar mul, dot product)
- Matrix type + basic ops (add, mul, transpose)
- Small numeric tests
- Implement
y = Wx + b - Mean Squared Error loss
- Gradient Descent optimizer
- Train/test on toy dataset
- Sigmoid activation
- Binary classification
- Cross-entropy loss
- Softmax function
- Multi-class classification
- Feedforward (1 hidden layer)
- Backpropagation
- Train on XOR
- Momentum optimizer
- Mini-batch training
- Matrix multiplication optimizations
- CSV loader
- Multilayer perceptron (MLP)
- MNIST (or subset)
odin-ml/
โโโ main.odin # entry point (demo runner)
โโโ core/ # basic building blocks
โ โโโ vector.odin
โ โโโ matrix.odin
โ โโโ math_utils.odin
โ โโโ notes.md
โโโ models/ # ML algorithms
โ โโโ linear_reg.odin
โ โโโ logistic_reg.odin
โ โโโ nn.odin
โ โโโ notes.md
โโโ datasets/ # toy datasets & loaders
โ โโโ csv_loader.odin
โ โโโ notes.md
โโโ optim/ # optimization algorithms
โ โโโ gradient_descent.odin
โ โโโ momentum.odin
โ โโโ notes.md
โโโ tests/ # unit tests
โโโ test_matrix.odin
โโโ notes.md
Each directory includes a notes.md file where I jot down design decisions, bugs, and future ideas for that module.
Clone the repo and run:
odin run .I only code on Sundays, so progress will be slow but steady.
The purpose is learning, not building a production-grade ML framework.
Expect bugs, incomplete features, and lots of iteration.
notes.md files track my thought process inside each module.
I don't know ๐คท๐ฟโโ๏ธ
I just want to learn Odin
Rarely used in ML โ great opportunity to explore.
Beyond the roadmap above, I plan to explore:
- Unsupervised learning algorithms (clustering, PCA, dimensionality reduction)
- Reinforcement learning experiments
- Small-scale neural network experiments beyond one hidden layer
- Performance optimizations and possible GPU/parallelism exploration(Maybe I am overthinking but I am willing to explore this.)
MIT โ free to use, learn from, and contribute.