Adding tested forward function and reactualized print data/network functions
This commit is contained in:
parent
1ee5cc0af4
commit
17e1c5562c
3 changed files with 31 additions and 6 deletions
12
main.c
12
main.c
|
@ -14,15 +14,19 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
printf("Bonjour et bienvenu ;)\n");
|
printf("Bonjour et bienvenu ;)\n");
|
||||||
|
|
||||||
/*int n_neurons[] = {15,120,220,120,200,25};
|
int n_neurons[] = {3,120,220,120,200,10};
|
||||||
char *activations[] = {"relu","relu","relu","relu","relu","relu"};
|
char *activations[] = {"relu","relu","relu","relu","relu","sigmoid"};
|
||||||
Network *net = init_network(n_neurons, 6, activations);
|
Network *net = init_network(n_neurons, 6, activations);
|
||||||
print_network(net);
|
print_network(net);
|
||||||
destroy_network(net);*/
|
|
||||||
|
|
||||||
Data *data = csv_to_samples("mydata.csv", 3, ",", 70.0, "yes", 3);
|
Data *data = csv_to_samples("mydata.csv", 3, ",", 70.0, "yes", 3);
|
||||||
print_data(data);
|
print_data(data);
|
||||||
destroy_data(data);
|
|
||||||
|
forward(net, data->first_sample);
|
||||||
|
print_network(net);
|
||||||
|
|
||||||
|
|
||||||
|
destroy_network(net);
|
||||||
|
destroy_data(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
21
network.c
21
network.c
|
@ -56,6 +56,9 @@ Network *init_network(int n_neurons_per_layer[], int n_layers, char *activation_
|
||||||
void print_network(const Network *network)
|
void print_network(const Network *network)
|
||||||
{
|
{
|
||||||
int i, n_params=0;
|
int i, n_params=0;
|
||||||
|
Neuron *temp;
|
||||||
|
printf("\n#>>==========================================<<#\n");
|
||||||
|
printf("# NEURAL NETWORK #\n");
|
||||||
printf("#>>==========================================<<#\n");
|
printf("#>>==========================================<<#\n");
|
||||||
printf(">> Number of layers : %d\n", network->n_layers);
|
printf(">> Number of layers : %d\n", network->n_layers);
|
||||||
printf("------------------------------------------------\n");
|
printf("------------------------------------------------\n");
|
||||||
|
@ -65,10 +68,26 @@ void print_network(const Network *network)
|
||||||
{
|
{
|
||||||
printf(">> Input layer\n");
|
printf(">> Input layer\n");
|
||||||
printf("size : %d\n", network->neurons_per_layer[i]);
|
printf("size : %d\n", network->neurons_per_layer[i]);
|
||||||
|
printf("neurons' outputs : ");
|
||||||
|
temp = network->layers_first_neurons[i];
|
||||||
|
while(temp != NULL)
|
||||||
|
{
|
||||||
|
printf("%f ", temp->output);
|
||||||
|
temp = temp->same_layer_next_neuron;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
}else if(i==network->n_layers-1)
|
}else if(i==network->n_layers-1)
|
||||||
{
|
{
|
||||||
printf(">> Output layer\n");
|
printf(">> Output layer\n");
|
||||||
printf("size : %d\n", network->neurons_per_layer[i]);
|
printf("size : %d\n", network->neurons_per_layer[i]);
|
||||||
|
printf("neurons' outputs : ");
|
||||||
|
temp = network->layers_first_neurons[i];
|
||||||
|
while(temp != NULL)
|
||||||
|
{
|
||||||
|
printf("%f ", temp->output);
|
||||||
|
temp = temp->same_layer_next_neuron;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
printf(">> Hidden layer %d\n", i);
|
printf(">> Hidden layer %d\n", i);
|
||||||
|
@ -82,7 +101,7 @@ void print_network(const Network *network)
|
||||||
n_params += network->neurons_per_layer[i] * (network->neurons_per_layer[i-1] + 1);
|
n_params += network->neurons_per_layer[i] * (network->neurons_per_layer[i-1] + 1);
|
||||||
}
|
}
|
||||||
printf("%d\n", n_params);
|
printf("%d\n", n_params);
|
||||||
printf("#>>==========================================<<#\n");
|
printf("#>>==========================================<<#\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy_network(Network *network)
|
void destroy_network(Network *network)
|
||||||
|
|
|
@ -175,6 +175,8 @@ void print_data(const Data *data)
|
||||||
Sample *current_sample = data->first_sample;
|
Sample *current_sample = data->first_sample;
|
||||||
Feature *temp_feature;
|
Feature *temp_feature;
|
||||||
OneHotLabel *temp_hotlabel;
|
OneHotLabel *temp_hotlabel;
|
||||||
|
printf("\n#=============================================#\n");
|
||||||
|
printf("# DATA #\n");
|
||||||
printf("#=============================================#\n");
|
printf("#=============================================#\n");
|
||||||
if(current_sample != NULL)
|
if(current_sample != NULL)
|
||||||
{
|
{
|
||||||
|
@ -219,5 +221,5 @@ void print_data(const Data *data)
|
||||||
{
|
{
|
||||||
printf("Nothing to print : empty data !!!\n");
|
printf("Nothing to print : empty data !!!\n");
|
||||||
}
|
}
|
||||||
printf("#=============================================#\n");
|
printf("#=============================================#\n\n");
|
||||||
}
|
}
|
Loading…
Reference in a new issue