Epitech · 3rd year · Solo
my_torch
A neural network written from scratch in NumPy that reads a chess position and tells check from checkmate.
- Python
- NumPy
- Deep learning
- Period
- Oct – Nov 2026
- Team
- Solo project
- Code
- View the code
The project
my_torch is a neural network module I wrote in Python with NumPy, without any deep learning library. Dense layers, activations, initialisers, losses, optimisers, mini-batches, L2 regularisation, early stopping, dropout and MC dropout, learning rate scheduling: everything is written by hand, backpropagation included.
I applied it to chess. From a position in FEN notation, encoded as 769 inputs, the network predicts Nothing, Check or Checkmate, and for which colour.
I play chess (1,400 Elo). Teaching a network what I see on the board, with no framework hiding the maths, was the best way to understand what really happens during training.
In numbers
- Check / Nothing, on the test split
- 95.7%
- Checkmate / Check / Nothing with colours, on the test split
- 90.0%
- positions from real games in the dataset
- 723,019
- tests passed on the grader
- 10 / 10
What was hard
- My first version, trained on 80,000 positions from random games, passed only 2 tests out of 10 on the grader. On real games it dropped to 53.6%: it saw checks everywhere.
- Writing backpropagation by hand, for six activations, with no framework to flag a mistake. Some errors stay invisible as long as you only use ReLU.
- Overfitting: without regularisation, 95.8% on training against 85.3% on validation.
What I learned
- Data matters more than architecture: switching to positions from real games gained more than 30 points, while the compared architectures differed by one point.
- Checking gradients with finite differences, on networks varied enough to expose the errors.
- Choosing on validation, measuring once on the test set, and fixing every seed so that each result can be reproduced exactly.
Try it.
The network, live
Place the pieces, or load a position. The real trained network runs in your browser with the Python code of the repository, and its answer is compared with the rules of chess.
The benchmarks
Every choice behind the final network was compared with its alternatives, on the same data.

Signal stability by initialiser 
Architectures · learning curves 
Architectures · summary 
Activations · learning curves 
Activations · summary 
Initialisers · learning curves 
Initialisers · summary 
Optimisers · learning curves 
Optimisers · summary 
Batch sizes · learning curves 
Batch sizes · summary 
Confusion matrix
Credits
- Chess pieces: Colin M.L. Burnett (BSD licence).
- Python in the browser: Pyodide (MPL 2.0). Rules of chess: chess.js (BSD).