Home | Develop | Download | Contact
example_load_test.c
1 /*
2  * example_load_test.c
3  *
4  * Copyright 2011 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  *
21  */
22 
32 #include <stdlib.h>
33 #include <math.h>
34 
35 #include <pds/pdsra.h>
36 #include <pds/pdsnn.h>
37 
38 // ./test/example_load_test ../test/data.mlayer
39 int main(int argc, char** argv)
40 {
41  PdsNnNatural i;
42  PdsNnNatural Ntests=4;
43  PdsNnNatural Nin,Nout;
44 
45  if(argc==1) return EXIT_FAILURE;
46 
47  // Loading the neural network from filepath in argv[1].
48  PdsNeuronML *MLayer=pds_neuronml_new_load_data(argv[1]);
49  if(MLayer==NULL) return EXIT_FAILURE;
50 
51  // Console print of head data in neural network.
53  printf("\n");
54 
55  // Creating temporal vectors X and Y.
58  PdsVector *X = pds_vector_new(Nin);
59  PdsVector *Y = pds_vector_new(Nout);
60  if( (X==NULL)||(Y==NULL) ) return EXIT_FAILURE;
61 
62  // Testing negative values.
63  for(i=0;i<Ntests;i++)
64  {
65  pds_generate_data_input_rand(X,1.0); // Loading randomly a negative data vector X
66 
67  pds_neuronml_iterate(MLayer,X,Y);
69  }
70 
71  printf("\n");
72 
73  // Testing positive values.
74  for(i=0;i<Ntests;i++)
75  {
76  pds_generate_data_input_func2pi(X,sin,6,0.05); // Loading randomly a positive data vector X
77 
78  pds_neuronml_iterate(MLayer,X,Y);
80  }
81 
82  printf("\n");
83 
84  pds_vector_free(X);
85  pds_vector_free(Y);
86  pds_neuronml_free(MLayer);
87 
88  return EXIT_SUCCESS;
89 }
90 
PdsNnBool pds_neuronml_iterate_results_printf(const PdsNeuronML *MLayer, const char *Type)
Muestra los resultados de la iteración de la red neuronal multicapa NeuronML.
La estructura tipo PdsNeuronML . Esta estructura genera una red neuronal multi capa. Para usar incluir pds/pdsnn.h.
Definition: pdsneuronml.h:74
void pds_neuronml_free(PdsNeuronML *NeuronML)
Libera una neurona de tipo puntero PdsNeuronML.
int pds_generate_data_input_rand(PdsVector *X, PdsNnReal A)
unsigned int PdsNnNatural
Definition: pdsnnglobal.h:62
int pds_neuronml_iterate(PdsNeuronML *NeuronML, const PdsVector *Input, PdsVector *Output)
Itera la red neuronal multicapa NeuronML. .
int pds_neuronml_get_number_of_output_neurons(PdsNeuronML *NeuronML, PdsNnNatural *Number)
Retorna o numero de neuronas de salida.
int pds_neuronml_head_printf(const PdsNeuronML *NeuronML)
Mostra em pantalla los datos de cabecera de la red neuronal multicapa.
int pds_neuronml_get_number_of_input_neurons(PdsNeuronML *NeuronML, PdsNnNatural *Number)
Retorna o numero de neuronas de entrada.
PdsNeuronML * pds_neuronml_new_load_data(const char *mlayer_filename)
Crea una estructura de tipo PdsNeuronML e inicia todos los elementos. desde un archivo de texto...
int pds_generate_data_input_func2pi(PdsVector *X, double(*func)(double), PdsNnReal C, PdsNnReal OffsetError)
Genera un vector con C ciclos de la función func() con un error de offset de valor OffsetError...

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed