Updating/Adding functions

This commit is contained in:
Abdel Kader Chabi Sika Boni 2021-11-27 11:16:46 +01:00
parent f716f8badb
commit ce66110173
2 changed files with 15 additions and 3 deletions

View file

@ -3,8 +3,17 @@
#include <string.h>
#include "neurons.h"
Neuron *init_neuron()
Neuron *init_neuron(int n_weights)
{
Neuron *neuron = (Neuron*)malloc(sizeof(Neuron));
neuron->weights = (float*)malloc(n_weights*sizeof(float));
neuron->output = 0.0;
neuron->delta_error = 0.0;
neuron->same_layer_next_neuron = NULL;
}
void destroy_neuron(Neuron *neuron)
{
free(neuron->weights);
free(neuron);
}

View file

@ -4,11 +4,14 @@
typedef struct neuron Neuron;
struct neuron
{
float output; //output of the neuron
float *weights; //weights associated to the neuron + neuron's bias
float output; //output of the neuron
float delta_error; //the delta error for updating current weights
Neuron *same_layer_next_neuron;
};
Neuron *init_neuron(int n_weights);
void destroy_neuron(Neuron *neuron);
#endif