mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-23 15:16:26 +01:00
cnn/neuron_io: track compatibility
This commit is contained in:
parent
0fb23c9b15
commit
13e786d34b
@ -38,6 +38,8 @@ uint32_t|linearisation|
|
|||||||
uint32_t|k_size|
|
uint32_t|k_size|
|
||||||
uint32_t|rows|
|
uint32_t|rows|
|
||||||
uint32_t|columns|
|
uint32_t|columns|
|
||||||
|
uint32_t|stride|
|
||||||
|
uint32_t|padding|
|
||||||
|
|
||||||
#### Si la couche est un nn:
|
#### Si la couche est un nn:
|
||||||
type | nom de la variable | commentaire
|
type | nom de la variable | commentaire
|
||||||
@ -52,6 +54,8 @@ type | nom de la variable | commentaire
|
|||||||
:---:|:---:|:---:
|
:---:|:---:|:---:
|
||||||
uint32_t|linearisation|
|
uint32_t|linearisation|
|
||||||
uint32_t|pooling|
|
uint32_t|pooling|
|
||||||
|
uint32_t|stride|
|
||||||
|
uint32_t|padding|
|
||||||
|
|
||||||
|
|
||||||
### Corps
|
### Corps
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
|
|
||||||
#include "include/neuron_io.h"
|
#include "include/neuron_io.h"
|
||||||
|
|
||||||
#define MAGIC_NUMBER 1012
|
#define INITIAL_MAGIC_NUMBER 1010
|
||||||
|
#define MAGIC_NUMBER 1013 // Increment this whenever you change the code
|
||||||
|
|
||||||
#define CNN 0
|
#define CNN 0
|
||||||
#define NN 1
|
#define NN 1
|
||||||
@ -114,13 +115,11 @@ void write_couche(Network* network, int indice_couche, int type_couche, FILE* pt
|
|||||||
Kernel_nn* nn = kernel->nn;
|
Kernel_nn* nn = kernel->nn;
|
||||||
|
|
||||||
// Écriture du pré-corps
|
// Écriture du pré-corps
|
||||||
uint32_t pre_buffer[6];
|
uint32_t pre_buffer[4];
|
||||||
pre_buffer[0] = kernel->activation;
|
pre_buffer[0] = kernel->activation;
|
||||||
pre_buffer[1] = kernel->linearisation;
|
pre_buffer[1] = kernel->linearisation;
|
||||||
pre_buffer[2] = nn->size_input;
|
pre_buffer[2] = nn->size_input;
|
||||||
pre_buffer[3] = nn->size_output;
|
pre_buffer[3] = nn->size_output;
|
||||||
pre_buffer[4] = kernel->stride;
|
|
||||||
pre_buffer[5] = kernel->padding;
|
|
||||||
fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr);
|
fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr);
|
||||||
|
|
||||||
// Écriture du corps
|
// Écriture du corps
|
||||||
@ -163,7 +162,12 @@ Network* read_network(char* filename) {
|
|||||||
|
|
||||||
(void) !fread(&magic, sizeof(uint32_t), 1, ptr);
|
(void) !fread(&magic, sizeof(uint32_t), 1, ptr);
|
||||||
if (magic != MAGIC_NUMBER) {
|
if (magic != MAGIC_NUMBER) {
|
||||||
printf_error("Incorrect magic number !\n");
|
printf_error((char*)"Incorrect magic number !\n");
|
||||||
|
if (INITIAL_MAGIC_NUMBER < magic && magic >= INITIAL_MAGIC_NUMBER) {
|
||||||
|
printf("\tThis backup is no longer supported\n");
|
||||||
|
printf("\tnPlease update it manually or re-train the network.\n");
|
||||||
|
printf("\t(You can update it with a script or manually with a Hex Editor)\n");
|
||||||
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,15 +334,15 @@ Kernel* read_kernel(int type_couche, int output_width, FILE* ptr) {
|
|||||||
// Lecture du "Pré-corps"
|
// Lecture du "Pré-corps"
|
||||||
kernel->nn = (Kernel_nn*)nalloc(1, sizeof(Kernel_nn));
|
kernel->nn = (Kernel_nn*)nalloc(1, sizeof(Kernel_nn));
|
||||||
kernel->cnn = NULL;
|
kernel->cnn = NULL;
|
||||||
uint32_t buffer[6];
|
uint32_t buffer[4];
|
||||||
(void) !fread(&buffer, sizeof(buffer), 1, ptr);
|
(void) !fread(&buffer, sizeof(buffer), 1, ptr);
|
||||||
|
|
||||||
kernel->activation = buffer[0];
|
kernel->activation = buffer[0];
|
||||||
kernel->linearisation = buffer[1];
|
kernel->linearisation = buffer[1];
|
||||||
kernel->nn->size_input = buffer[2];
|
kernel->nn->size_input = buffer[2];
|
||||||
kernel->nn->size_output = buffer[3];
|
kernel->nn->size_output = buffer[3];
|
||||||
kernel->stride = buffer[4];
|
kernel->padding = -1;
|
||||||
kernel->padding = buffer[5];
|
kernel->stride = -1;
|
||||||
|
|
||||||
// Lecture du corps
|
// Lecture du corps
|
||||||
Kernel_nn* nn = kernel->nn;
|
Kernel_nn* nn = kernel->nn;
|
||||||
|
Loading…
Reference in New Issue
Block a user