42 for (
int i=0;i<v->
size;i++)
59 FILE *imageFile, *labelFile;
84 if (classification!=lbl) errCount++;
109 FILE *imageFile, *labelFile;
131 if (classification!=lbl) errCount++;
153 int main(
int argc,
const char * argv[]) {
156 time_t startTime = time(NULL);
160 printf(
" MNIST-3LNN: a simple 3-layer neural network processing the MNIST handwritten digit images\n\n");
177 time_t endTime = time(NULL);
178 double executionTime = difftime(endTime, startTime);
179 printf(
"\n DONE! Total execution time: %.1f sec\n\n",executionTime);
Dynamic data structure containing defined number of values.
#define MNIST_TRAINING_SET_IMAGE_FILE_NAME
MNIST image training file in the data folder.
Utitlies for displaying processing details in the terminal.
FILE * openMNISTImageFile(char *fileName)
Read MNIST IMAGE file header.
uint8_t pixel[MNIST_IMG_WIDTH *MNIST_IMG_HEIGHT]
int main(int argc, const char *argv[])
Neural network functionality for a 3-layer (INPUT, HIDDEN, OUTPUT) feed-forward, back-prop NN...
void trainNetwork(Network *nn)
Training the network by processing the MNIST training set and updating the weights.
void displayTrainingProgress(int imgCount, int errCount, int y, int x)
Outputs reading progress while processing MNIST training images.
#define MNIST_TESTING_SET_LABEL_FILE_NAME
MNIST label testing file in the data folder.
Utitlies for advanced input and output to terminal screen.
void feedForwardNetwork(Network *nn)
Feeds input layer values forward to hidden to output layer (calculation and activation fct) ...
void backPropagateNetwork(Network *nn, int targetClassification)
Back propagates network error from output layer to hidden layer.
FILE * openMNISTLabelFile(char *fileName)
Read MNIST label file header.
MNIST_Label getLabel(FILE *labelFile)
Returns the next label in given MNIST label file.
#define MNIST_TRAINING_SET_LABEL_FILE_NAME
MNIST label training file in the data folder.
#define MNIST_MAX_TESTING_IMAGES
number of images+labels in the TEST file/s
int getNetworkClassification(Network *nn)
Returns the network's classification using the ID of teh node with the hightest output.
void locateCursor(const int row, const int col)
Set cursor position to given coordinates in the terminal window.
#define MNIST_IMG_HEIGHT
image height in pixel
void feedInput(Network *nn, Vector *v)
Feeds some Vector data into the INPUT layer of the NN.
void clearScreen()
Clear terminal screen by printing an escape sequence.
#define MNIST_IMG_WIDTH
image width in pixel
#define MNIST_TESTING_SET_IMAGE_FILE_NAME
MNIST image testing file in the data folder.
Network * createNetwork(int inpCount, int hidCount, int outCount)
Creates a dynamically-sized, 3-layer (INTPUT, HIDDEN, OUTPUT) neural network.
Vector * getVectorFromImage(MNIST_Image *img)
Returns a Vector holding the image pixels of a given MNIST image.
Utitlies for handling the MNIST files.
MNIST_Image getImage(FILE *imageFile)
Returns the next image in given MNIST image file.
void displayTestingProgress(int imgCount, int errCount, int y, int x)
Data block defining a MNIST image.
#define MNIST_MAX_TRAINING_IMAGES
number of images+labels in the TRAIN file/s
Dynamic data structure holding the whole network.
void testNetwork(Network *nn)
Testing the trained network by processing the MNIST testing set WITHOUT updating weights.