This repo contains everything needed to train a CNN using SGD to learn the MNIST dataset.
Running ./compileall
will generate the following programs:
- main : running
./main
will start a new training session from randomly initialized weights using the hyperparameters and network defined in main.c and network.c - test : running
./test model.bin
will load the modelmodel.bin
and process all 10 000 test images from MNIST dataset, outputting the average accuracy of the model. - demo : running
./demo model.bin image
will load the modelmodel.bin
and the imageimage.pgm
, processing the image in the network and outputting a prediction. - featuremaps : running
./featuremaps model.bin image
will do the same as./demo
but will also generate the feature maps generated by the convolutional layers of the network in .pgm format.
./main
and ./test
need the /data folder to access the MNIST binary files.
This is mostly a naive implementation, most memory leaks have been addressed, but there might still be some bugs left.
The file mnist.h used for loading the MNIST dataset was adapted from MNIST for C by Takafumi Horiuchi.