Updating/Adding functions
This commit is contained in:
parent
f716f8badb
commit
ce66110173
2 changed files with 15 additions and 3 deletions
13
neurons.c
13
neurons.c
|
|
@ -3,8 +3,17 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "neurons.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);
|
||||||
|
}
|
||||||
|
|
@ -4,11 +4,14 @@
|
||||||
typedef struct neuron Neuron;
|
typedef struct neuron Neuron;
|
||||||
struct neuron
|
struct neuron
|
||||||
{
|
{
|
||||||
float output; //output of the neuron
|
|
||||||
float *weights; //weights associated to the neuron + neuron's bias
|
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
|
float delta_error; //the delta error for updating current weights
|
||||||
Neuron *same_layer_next_neuron;
|
Neuron *same_layer_next_neuron;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Neuron *init_neuron(int n_weights);
|
||||||
|
void destroy_neuron(Neuron *neuron);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Reference in a new issue