mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-23 23:26:25 +01:00
Update neuron_io
This commit is contained in:
parent
45c39d8880
commit
986707af2b
@ -11,8 +11,15 @@
|
||||
Neuron* read_neuron(uint32_t nb_weights, FILE *ptr);
|
||||
Neuron** read_neurons(uint32_t nb_neurons, uint32_t nb_weights, FILE *ptr);
|
||||
Network* read_network(char* filename);
|
||||
void ecrire_neuron(Neuron* neuron, int weights, FILE *ptr);
|
||||
|
||||
void write_neuron(Neuron* neuron, int weights, FILE *ptr);
|
||||
void write_network(char* filename, Network* network);
|
||||
|
||||
Neuron* read_delta_neuron(uint32_t nb_weights, FILE *ptr);
|
||||
Neuron** read_delta_neurons(uint32_t nb_neurons, uint32_t nb_weights, FILE *ptr);
|
||||
Network* read_delta_network(char* filename);
|
||||
|
||||
void write_delta_neuron(Neuron* neuron, int weights, FILE *ptr);
|
||||
void write_delta_network(char* filename, Network* network);
|
||||
|
||||
#endif
|
||||
|
@ -27,11 +27,9 @@ Neuron* read_neuron(uint32_t nb_weights, FILE *ptr) {
|
||||
neuron->last_back_bias = 0.0;
|
||||
neuron->back_bias = 0.0;
|
||||
|
||||
float* weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
|
||||
neuron->last_back_weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
neuron->back_weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
neuron->weights = weights;
|
||||
neuron->weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
|
||||
for (int i=0; i < (int)nb_weights; i++) {
|
||||
fread(&tmp, sizeof(float), 1, ptr);
|
||||
@ -40,7 +38,6 @@ Neuron* read_neuron(uint32_t nb_weights, FILE *ptr) {
|
||||
neuron->last_back_weights[i] = 0.0;
|
||||
}
|
||||
|
||||
free(weights);
|
||||
return neuron;
|
||||
}
|
||||
|
||||
@ -160,11 +157,9 @@ Neuron* read_delta_neuron(uint32_t nb_weights, FILE *ptr) {
|
||||
neuron->last_back_bias = 0.0;
|
||||
neuron->back_bias = back_bias;
|
||||
|
||||
float* back_weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
|
||||
neuron->last_back_weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
neuron->back_weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
neuron->weights = back_weights;
|
||||
neuron->weights = (float*)malloc(sizeof(float)*nb_weights);
|
||||
|
||||
for (int i=0; i < (int)nb_weights; i++) {
|
||||
fread(&tmp, sizeof(float), 1, ptr);
|
||||
@ -172,7 +167,6 @@ Neuron* read_delta_neuron(uint32_t nb_weights, FILE *ptr) {
|
||||
neuron->back_weights[i] = tmp;
|
||||
neuron->last_back_weights[i] = 0.0;
|
||||
}
|
||||
free(back_weights);
|
||||
return neuron;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user