-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_reader.c
72 lines (61 loc) · 2.02 KB
/
test_reader.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include "mnist_reader.h"
#include "matrix.h"
int main(void) {
matrix *train_images[60000];
char *fileimages = "/home/kinny/Study/demo/train_images.txt";
readImageDataAsVectorArray(fileimages, &train_images, 60000, 28*28);
int i, j;
double elem;
for (i = 0; i < 10; i++) {
for (j = 1; j <= 28*28; j++) {
getElement(train_images[i], j, 1, &elem);
if (j % 28 == 1) printf("\n");
printf("%6.2f ", elem);
}
printf("\n");
}
printf("\n");
matrix *train_labels[60000];
char *filelabels = "/home/kinny/Study/demo/train_labels.txt";
readLabelDataAsVectorArray(filelabels, &train_labels, 60000, 10);
for (j = 1; j <= 10; j++) {
for (i = 0; i < 10; i++) {
getElement(train_labels[i], j, 1, &elem);
printf("%6.2f ", elem);
}
printf("\n");
}
for (i = 0; i < 60000; i++) {
deleteMatrix(train_images[i]);
deleteMatrix(train_labels[i]);
}
printf("-----------------------------------------------------------------------------------\n");
matrix *test_images[10000];
char *testfileimages = "/home/kinny/Study/demo/test_images.txt";
readImageDataAsVectorArray(testfileimages, &test_images, 10000, 28*28);
for (i = 0; i < 10; i++) {
for (j = 1; j <= 28*28; j++) {
getElement(test_images[i], j, 1, &elem);
if (j % 28 == 1) printf("\n");
printf("%6.2f ", elem);
}
printf("\n");
}
printf("\n");
matrix *test_labels[10000];
char *testfilelabels = "/home/kinny/Study/demo/test_labels.txt";
readLabelDataAsVectorArray(testfilelabels, &test_labels, 10000, 10);
for (j = 1; j <= 10; j++) {
for (i = 0; i < 10; i++) {
getElement(test_labels[i], j, 1, &elem);
printf("%6.2f ", elem);
}
printf("\n");
}
for (i = 0; i < 10000; i++) {
deleteMatrix(test_images[i]);
deleteMatrix(test_labels[i]);
}
return 0;
}