dovrebbe convergere su mnist, da completare con persistenza e visualizzatore

This commit is contained in:
2026-03-25 13:00:09 +01:00
parent 524f33a690
commit 0b31a0e0d7
13 changed files with 528 additions and 675 deletions
+11 -6
View File
@@ -19,6 +19,11 @@ Byte 8 in poi: 60.000 byte, ognuno dei quali rappresenta l'etichetta di un'immag
#include <stdlib.h>
#include <stdio.h>
char *file_immagini = "mnist/t10k-images.idx3-ubyte";
char *file_label = "mnist/t10k-labels.idx1-ubyte";
// char *file_immagini = "mnist/train-images.idx3-ubyte";
// char *file_label = "mnist/train-labels.idx1-ubyte";
#define N_INPUTS 784 // Immagine 28x28
// Siccome il char è un byte che rappresenta il valore tra 0 e 255. Per evitare confusioni definisco il tipo "byte" come in Java
@@ -38,24 +43,24 @@ typedef struct
Istanza *istanze;
} Dataset;
Dataset *get_dataset(char *, char *);
Dataset *get_dataset();
// Questo metodo legge il file in questione e restituisce un puntatore a Dataset se il file esiste, altrimenti NULL
// Ritorna un puntatore perchè in questo caso posso gestire il ritorno NULL.
Dataset *get_dataset(char *path_mnist, char *path_categoria)
Dataset *get_dataset()
{
Dataset *set = (Dataset *)malloc(sizeof(Dataset));
FILE *file;
FILE *categorie;
Istanza *istanze = (Istanza *)malloc(sizeof(Istanza));
file = fopen(path_mnist, "rb");
file = fopen(file_immagini, "rb");
if (file == NULL) {
printf("Errore nella funzione fopen() nelle immagini\n");
return NULL;
}
categorie = fopen(path_categoria, "rb");
categorie = fopen(file_label, "rb");
if (file == NULL) {
printf("Errore nella funzione fopen() nelle categorie\n");
return NULL;
@@ -74,8 +79,8 @@ Dataset *get_dataset(char *path_mnist, char *path_categoria)
}
// Dataset set;
(*set).size = numero_righe;
(*set).istanze = istanze;
set->size = numero_righe;
set->istanze = istanze;
fclose(file);
return set;