Machine learning · From scratch
My Torch
Machine learning · From scratch
My Torch
Neural network library written from scratch, without PyTorch or TensorFlow, trained to detect checkmate and check in chess positions (FEN).
My Torch is a neural network library written from scratch for Epitech's AI module, with one rule: no PyTorch, no TensorFlow. Every piece that frameworks usually hide had to be implemented and understood by hand. I built it alone in four weeks. The library implements the full training loop. The forward pass computes the network's prediction layer by layer; backpropagation then computes how much each weight contributed to the error, and mini-batch gradient descent updates the weights in small steps over batches of examples. Weights start from Xavier initialisation, which keeps signals at a healthy scale through the layers so training does not stall from the start. A network that learns its training data by heart is useless on new data, so the library also includes techniques to prevent overfitting, and I tuned the hyperparameters (learning rate, batch size, network size) by comparing results on data the model had never seen. To prove the library works, I applied it to a real task: a chess position analyser. Each position is given in FEN notation, the standard text format for chess boards, converted into numbers the network can read, and classified by supervised learning into three classes: Checkmate, Check or Nothing. Building what frameworks do for you is the best way to understand them: this project gave me a precise intuition of how neural networks learn, why they fail and how to make them train well.
Built with