Home | Develop | Download | Contact
testprog1.c
1 /*
2  * testprog1.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 <pds/pdssn.h>
34 
35 int main(int argc, char** argv)
36 {
37  PdsNeuron *Neuron=NULL;
38  PdsSnReal m;
39  PdsNInput *A[4];
40 
42 
43  Neuron=pds_neuron_new(4);
44  if(Neuron==NULL) printf("ERROR: La neurona no ha podido crearse.\n");
45  else
46  {
47  A[0]=pds_ninput_new(); pds_ninput_set_input(A[0], 1.0);
48  A[1]=pds_ninput_new(); pds_ninput_set_input(A[1], 0.5);
49  A[2]=pds_ninput_new(); pds_ninput_set_input(A[2],-0.3);
50  A[3]=pds_ninput_new(); pds_ninput_set_input(A[3],-1.7);
51 
56  printf("X{:}=\n%f\t%f\t%f\t%f\n\n",*(Neuron->X[0]),*(Neuron->X[1]),*(Neuron->X[2]),*(Neuron->X[3]));
57 
58  pds_neuron_set_weight(Neuron,0,1.3);
59  pds_neuron_set_weight(Neuron,1,-3.2);
60  pds_neuron_set_weight(Neuron,2,0.1);
61  pds_neuron_set_weight(Neuron,3,4.5);
62  printf("W{:}=\n%f\t%f\t%f\t%f\n\n",Neuron->W[0],Neuron->W[1],Neuron->W[2],Neuron->W[3]);
63 
64  pds_neuron_set_u(Neuron,0.0);
65 
66  pds_neuron_iterate(Neuron);
67 
68  pds_neuron_get_output(Neuron,&m);
69  printf("Y=%f\n",m);
70 
71  pds_ninput_destroy(&A[0]);
72  pds_ninput_destroy(&A[1]);
73  pds_ninput_destroy(&A[2]);
74  pds_ninput_destroy(&A[3]);
75 
76  pds_neuron_destroy(&Neuron);
77  if(Neuron==NULL) printf("\nLa neurona Neuron ha sido liberado y limpiada.\n");
78  }
80 
81  printf("\n");
82 
83  return EXIT_SUCCESS;
84 }
PdsSnReal ** X
Definition: pdsneuron.h:80
PdsSnReal * W
Definition: pdsneuron.h:83
int pds_neuron_set_weight(PdsNeuron *Neuron, PdsSnNatural x, PdsSnReal m)
Escribe el valor m en la posición (x) del vector de pesos de la Neurona. (x) inicia con (0)...
int pds_ninput_set_input(PdsNInput *NInput, PdsSnReal m)
Escribe el valor en la entrada de la neurona NInput.
PdsNInput * pds_ninput_new(void)
Crea una neurona de tipo PdsNInput e inicia con cero todos los elementos.
La estructura tipo PdsNInput . Esta estructura genera una neurona de entrada.
Definition: pdsninput.h:69
int pds_neuron_get_output(const PdsNeuron *Neuron, PdsSnReal *m)
Devuelve el valor de la salida Y de la Neurona.
void pds_neuron_destroy(PdsNeuron **Neuron)
Libera una neurona de tipo puntero PdsNeuron, y limpia el puntero con NULL.
int pds_neuron_iterate(PdsNeuron *Neuron)
Itera la Neurona Neuron. Adicionalmente (Neuron->Y[1]=0) .
void pds_ninput_destroy(PdsNInput **NInput)
Libera una neurona de tipo puntero PdsNInput, y limpia el puntero con NULL.
int pds_neuron_connect_input_with_ninput(PdsNeuron *Neuron, PdsSnNatural id, PdsNInput *NInput)
Conecta el valor de salida Y de la neurona de entrada NInput con la entrada X[id] de la neurona Neuro...
La estructura tipo PdsNeuron . Esta estructura genera una neurona de Nel entradas.
Definition: pdsneuron.h:77
float PdsSnReal
Definition: pdssnglobal.h:50
int pds_neuron_set_u(PdsNeuron *Neuron, PdsSnReal U)
Coloca el valor de U de la Neurona.
PdsNeuron * pds_neuron_new(PdsSnNatural Nel)
Crea una neurona de tipo PdsNeuron de Nel entradas.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed