12 if (net == NULL)
return NULL;
15 if (net->
layers == NULL)
return NULL;
23 if (net == NULL)
return;
24 for(
size_t i = 0; i < net->
size; ++i)
33 if (net == NULL)
return;
34 for(
size_t i = 0; i < net->
size; ++i)
41 if (net == NULL || l == NULL)
return 1;
44 if (net->
layers == NULL)
return -1;
52 if (net == NULL)
return 1;
54 for(
size_t i = 0; i < net->
size && e == 0; ++i)
59 for(
size_t i = 0; e == 0 && i < net->
size; ++i)
72 if (len < 1 || spec == NULL || f_act == NULL || f_act_de == NULL)
75 if (net == NULL)
return NULL;
77 for(
size_t i = 0; i < len; ++i)
97 if (net == NULL)
return 0;
100 for (
size_t i = 0; i < net->
size; ++i)
114 if (net == NULL || param == NULL)
return;
115 param[0] = param[1] = param[2] = param[4]= 0;
116 param[3] = net->
size;
118 for (
size_t i = 0; i < net->
size; ++i)
128 if (net == NULL)
return;
132 printf(
"===\n PCFNN_NETWORK: summary\n* Neural network ram usage: ");
134 printf(
"%ld o", param[2]);
135 else if (param[2] < 1000000 && param[2] > 1000)
136 printf(
"%.2f Ko", (
double)param[2] / 1000.);
137 else if (param[2] < 1000000000 && param[2] > 1000000)
138 printf(
"%.2f Mo", (
double)param[2] / 1000000.);
139 else if (param[2] < 1000000000000 && param[2] > 1000000000)
140 printf(
"%.2f Go", (
double)param[2] / 1000000000.);
142 printf(
"%.2f To", (
double)param[2] / 1000000000000.);
143 printf(
"\n* Number of layers: %ld\n* Number of neurons: %ld\n--\n* Layer summary: \n", param[3], param[4]);
144 for (
size_t i = 0; i < net->
size; ++i)
151 printf(
" - [%c] layer: n°%ld : %ld neurons\n" 156 printf(
" - %ld -> %ld | (%ld, %ld) -> (%ld, %ld)\n",
160 printf(
"--\n* Number of unlocked parameters: %ld\n* Number of locked parameters: %ld\n===\n", param[0], param[1]);
int PCFNN_LAYER_connect(struct PCFNN_LAYER *from, struct PCFNN_LAYER *to, size_t size_from, size_t size_to, size_t offset_from, size_t offset_to, double(*f_init_to)(), double(*f_act_to)(double), double(*f_act_de_to)(double))
Connect two PCFNN_LAYER. It will create a link between from and to.
void PCFNN_LAYER_free(struct PCFNN_LAYER *l)
Free all memory allocation of an PCFNN_LAYER (It will call PCFNN_NEURON_free)
void PCFNN_LAYER_clear(struct PCFNN_LAYER *l)
Clear all neurons in the layer l (It will call PCFNN_NEURON_clear)
struct PCFNN_LAYER * inputl
int PCFNN_LAYER_build(struct PCFNN_LAYER *l)
Initialize all internal data of the layer l and build of PCFNN_NEURON it contains.
struct PCFNN_LAYER ** layers
double(* f_act_de)(double)
Structure to represent a link between to PCFNN_LAYER.
struct PCFNN_LAYER_LINK ** links
void PCFNN_NETWORK_print_summary(struct PCFNN_NETWORK *net)
Print neural network summary.
size_t PCFNN_LAYER_get_ram_usage(struct PCFNN_LAYER *l)
Give the number of bytes used by the PCFNN_LAYER l and all PCFNN_NEURON it contains.
struct PCFNN_LAYER * outputl
struct PCFNN_LAYER * PCFNN_LAYER_new_input(size_t size, double(*f_act)(double), double(*f_act_de)(double))
Initialize a PCFNN_LAYER as an input layer.
struct PCFNN_NETWORK * PCFNN_NETWORK_build_from_array(size_t *spec, size_t len, double(*f_init)(double), double(*f_act)(double), double(*f_act_de)(double))
Initialize a new PCFNN_NETWORK from an array of number that represent the number of neurons for each ...
void PCFNN_NETWORK_clear(struct PCFNN_NETWORK *net)
Clear all layers in the PCFNN_NETWORK net (It will call PCFNN_LAYER_clear)
void PCFNN_NETWORK_free(struct PCFNN_NETWORK *net)
Free all memory allocation of an PCFNN_NETWORK (It will call PCFNN_LAYER_free)
void PCFNN_LAYER_summary(struct PCFNN_LAYER *l, size_t param[2])
Write on param the number of unlocked parameters and locked parameters.
int PCFNN_NETWORK_addl(struct PCFNN_NETWORK *net, struct PCFNN_LAYER *l)
Add the PCFNN_LAYER l to the PCFNN_NETWORK net.
void PCFNN_NETWORK_summary(struct PCFNN_NETWORK *net, size_t param[5])
Write on param network statistics.
struct PCFNN_NETWORK * PCFNN_NETWORK_new()
Initialize a PCFNN_NETWORK.
size_t PCFNN_NETWORK_get_ram_usage(struct PCFNN_NETWORK *net)
Give the number of bytes used by the PCFNN_NETWORK net and all PCFNN_LAYER it contains.
enum PCFNN_LAYER_TYPE type
int PCFNN_NETWORK_build(struct PCFNN_NETWORK *net)
Initialize all internal data of the PCFNN_NETWORK l and build of PCFNN_LAYER it contains.
struct PCFNN_LAYER * from
struct PCFNN_LAYER * PCFNN_LAYER_new(double(*f_init)(), double(*f_act)(double), double(*f_act_de)(double))