tipe/test/dense_data_io.c

62 lines
1.6 KiB
C
Raw Normal View History

2022-04-02 16:15:27 +02:00
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
2023-05-12 16:16:34 +02:00
#include "../src/common/include/colors.h"
#include "../src/common/include/mnist.h"
2022-04-02 16:15:27 +02:00
2022-04-25 14:39:45 +02:00
void read_test(int nb_images, int width, int height, int*** images, unsigned int* labels) {
2022-04-02 16:15:27 +02:00
printf("\tLecture des labels\n");
for (int i=0; i < nb_images; i++) {
(void)labels[i];
}
printf(GREEN "\tOK\n" RESET);
2022-04-02 16:15:27 +02:00
printf("\tLecture des images\n");
for (int i=0; i < nb_images; i++) {
for (int j=0; j < height; j++) {
for (int k=0; k < width; k++) {
(void)images[i][j][k];
}
}
}
printf(GREEN "\tOK\n" RESET);
2022-04-02 16:15:27 +02:00
}
int main() {
char* image_file = (char*)"data/mnist/t10k-images-idx3-ubyte";
char* labels_file = (char*)"data/mnist/t10k-labels-idx1-ubyte";
2022-04-02 16:15:27 +02:00
printf("Chargement des paramètres\n");
int* parameters = read_mnist_images_parameters(image_file);
int nb_images = parameters[0];
int height = parameters[1];
int width = parameters[2];
printf(GREEN "OK\n" RESET);
2022-04-02 16:15:27 +02:00
printf("Chargement des images\n");
int*** images = read_mnist_images(image_file);
printf(GREEN "OK\n" RESET);
2022-04-02 16:15:27 +02:00
printf("Chargement des labels\n");
unsigned int* labels = read_mnist_labels(labels_file);
printf(GREEN "OK\n" RESET);
2022-04-02 16:15:27 +02:00
printf("Vérification de l'accès en lecture\n");
2022-04-25 14:39:45 +02:00
read_test(nb_images, width, height, images, labels);
2022-04-02 16:15:27 +02:00
printf(GREEN "OK\n" RESET);
2023-01-14 14:30:34 +01:00
for (int i=0; i < nb_images; i++) {
for (int j=0; j < height; j++) {
free(images[i][j]);
}
free(images[i]);
}
free(images);
free(labels);
free(parameters);
2022-05-14 16:04:35 +02:00
return 0;
2022-04-02 16:15:27 +02:00
}