Deep Neural Network for MNIST Handwriting Recognition  1.0
Deep Neural Network for MNIST Handwriting Recognition
mnist-utils.h
Go to the documentation of this file.
1 
9 #ifndef MNIST_UTILS_HEADER
10 #define MNIST_UTILS_HEADER
11 
12 
13 
14 
15 // Include external libraries
16 #include <stdint.h>
17 #include <stdio.h>
18 
19 // Define locations of MNIST data set files
20 #define MNIST_TRAINING_SET_IMAGE_FILE_NAME "./data/train-images-idx3-ubyte"
21 #define MNIST_TRAINING_SET_LABEL_FILE_NAME "./data/train-labels-idx1-ubyte"
22 #define MNIST_TESTING_SET_IMAGE_FILE_NAME "./data/t10k-images-idx3-ubyte"
23 #define MNIST_TESTING_SET_LABEL_FILE_NAME "./data/t10k-labels-idx1-ubyte"
24 
26 #define MNIST_MAX_TRAINING_IMAGES 60000
27 
29 #define MNIST_MAX_TESTING_IMAGES 10000
30 
31 // Define image size in pixels
32 #define MNIST_IMG_WIDTH 28
33 #define MNIST_IMG_HEIGHT 28
34 
35 
36 
39 
40 typedef struct MNIST_Image MNIST_Image;
41 typedef uint8_t MNIST_Label;
42 
43 
44 typedef struct Vector Vector;
45 
46 
47 
48 
53 struct Vector{
54  int count; // number of values in the vector
55  double vals[]; // array of values inside the vector
56 };
57 
58 
59 
60 
65 struct MNIST_Image{
67 };
68 
69 
70 
71 
81  uint32_t magicNumber;
82  uint32_t maxImages;
83  uint32_t imgWidth;
84  uint32_t imgHeight;
85 };
86 
87 
88 
89 
99  uint32_t magicNumber;
100  uint32_t maxImages;
101 };
102 
103 
104 
105 
112 FILE *openMNISTImageFile(char *fileName);
113 
114 
115 
116 
123 FILE *openMNISTLabelFile(char *fileName);
124 
125 
126 
131 MNIST_Image getImage(FILE *imageFile);
132 
133 
134 
135 
140 MNIST_Image getImageByPosition(FILE *imageFile, int position);
141 
142 
143 
148 MNIST_Label getLabel(FILE *labelFile);
149 
150 
151 
152 
157 MNIST_Label getLabelByPosition(FILE *labelFile, int position);
158 
159 
160 
161 
168 
169 
170 
171 
172 #endif
173 
174 
175 
Variably-sized data structure defining a vector with "count" doubles.
Definition: mnist-utils.h:53
uint8_t pixel[MNIST_IMG_WIDTH *MNIST_IMG_HEIGHT]
Definition: mnist-utils.h:66
uint32_t maxImages
Definition: mnist-utils.h:100
uint32_t imgHeight
Definition: mnist-utils.h:84
MNIST_Label getLabelByPosition(FILE *labelFile, int position)
Definition: mnist-utils.c:202
int count
Definition: mnist-utils.h:54
Vector * getVectorFromImage(MNIST_Image *img)
Returns a Vector holding the image pixels of a given MNIST image.
Definition: mnist-utils.c:224
FILE * openMNISTLabelFile(char *fileName)
Returns a file pointer to the MNIST label file.
Definition: mnist-utils.c:119
double vals[]
Definition: mnist-utils.h:55
#define MNIST_IMG_HEIGHT
Definition: mnist-utils.h:33
Data block defining a MNIST image file header.
Definition: mnist-utils.h:80
Data block defining a MNIST label file header.
Definition: mnist-utils.h:98
MNIST_Image getImageByPosition(FILE *imageFile, int position)
Definition: mnist-utils.c:161
#define MNIST_IMG_WIDTH
Definition: mnist-utils.h:32
MNIST_Image getImage(FILE *imageFile)
Returns the next image in given MNIST image file.
Definition: mnist-utils.c:141
uint32_t magicNumber
Definition: mnist-utils.h:81
MNIST_Label getLabel(FILE *labelFile)
Returns the next label in given MNIST label file.
Definition: mnist-utils.c:182
uint32_t maxImages
Definition: mnist-utils.h:82
uint32_t magicNumber
Definition: mnist-utils.h:99
FILE * openMNISTImageFile(char *fileName)
Returns a file pointer to the MNIST image file.
Definition: mnist-utils.c:95
uint32_t imgWidth
Definition: mnist-utils.h:83
Data block defining a MNIST image.
Definition: mnist-utils.h:65
uint8_t MNIST_Label
Definition: mnist-utils.h:41