This is an attempt to build a simple image recognition neural network from scratch with kotlin. The network is modelled mostly in an object-oriented fashion and implemented without matrix calculations or 3rd party dependencies. The point is to try to understand its inner workings in a more concrete fashion. This is not an attempt to create an exceptionally well-performing and effective solution.
Please also have a look at the React application which uses the network trained by this project.
Demo hosted at: https://neural-network.joosa.net/
Demo source code: https://github.com/Joosakur/neural-network-demo
By default, the data used for training and testing is a set of grayscale images of handwritten digits with a 28x28 px resolution.
Download the four data files from http://yann.lecun.com/exdb/mnist/ and extract to project root.
To run the application (train and test network) execute command ./gradlew run
Network without any hidden layers works surprisingly well.
Network with two hidden layers of 16 neurons with ReLU activation seems to give poor results.
Network with two hidden layers of 16 neurons with Sigmoid activation, and all layers connected to every other layer seems to give rather good results.
Network with convolution layers for edge detection gives clearly the best results.
These debug graphics demonstrate how it discovers edges in four directions.
Developed by Joosa Kurvinen