Skip to content

gafaua/cnn-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple CNN written from scratch in C

This repo contains everything needed to train a CNN using SGD to learn the MNIST dataset.

Compiling

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 model model.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 model model.bin and the image image.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.

Disclaimer

This is mostly a naive implementation, most memory leaks have been addressed, but there might still be some bugs left.

Acknowledgement

The file mnist.h used for loading the MNIST dataset was adapted from MNIST for C by Takafumi Horiuchi.

About

A simple CNN written from scratch in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published