Home | Develop | Download | Contact
example.c
1 
2 #include <stdlib.h>
3 #include <pds/pdssn.h>
4 
5 
6 int main(int argc, char** argv)
7 {
8  PdsSnReal X[4]={1.0, 0.5, -0.3, -1.7};
9  PdsSnNatural N=4;
10  PdsSnReal Out;
11 
12  // Creating an input vector of N elements
13  PdsNIVector *Input=pds_nivector_new(N);
14  // Creating a neuron with N inputs
15  PdsNeuron *Neuron=pds_neuron_new(N);
16 
17  if( (Input==NULL)||(Neuron==NULL) ) return EXIT_FAILURE;
18 
19  // Connect the input vector with the input of neuron
21 
22  // Initializing weights and print the values
23  pds_neuron_init_u_and_weight_rand(Neuron,-1.0,+1.0);
25 
26  // Copy the X array in the input vector
28 
29  // Iterate the neuron
30  pds_neuron_iterate(Neuron);
31 
32  // Get the output value of neuron
33  pds_neuron_get_output(Neuron,&Out);
34  printf("Y=%7.3f\n",Out);
35 
36  // Release the memory
37  pds_nivector_destroy(&Input);
38  pds_neuron_destroy(&Neuron);
39 
40  return EXIT_SUCCESS;
41 }
int pds_neuron_connect_input_with_nivector(PdsNeuron *Neuron, const PdsNIVector *NIVector)
Conecta el valor de salida Y de las neuronas NIVector con la entrada X[id] de la neurona Neuron...
int pds_nivector_set_input_from_array(PdsNIVector *NIVector, const PdsSnReal *X, int Nel)
Escribe el valor de la entrada de las Neuronas.
int pds_neuron_printf_u_and_weight(const PdsNeuron *Neuron)
Imprime los valores de U y los pesos en la Neurona.
int pds_neuron_init_u_and_weight_rand(PdsNeuron *Neuron, PdsSnReal min, PdsSnReal max)
Inicia el vector de pesos y U de la Neurona con valores aleatorios uniformemente distribuido entre mi...
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_nivector_destroy(PdsNIVector **NIVector)
Libera un vector de neuronas de tipo puntero PdsNIVector, y limpia el puntero con NULL...
La estructura tipo PdsNIVector . Esta estructura genera un arreglo de neuronas. Para usar incluir pds...
Definition: pdsnivector.h:80
La estructura tipo PdsNeuron . Esta estructura genera una neurona de Nel entradas.
Definition: pdsneuron.h:77
float PdsSnReal
Definition: pdssnglobal.h:50
PdsNIVector * pds_nivector_new(PdsSnNatural Nel)
Crea un vector de neuronas de entrada de tipo PdsNIVector e inicia con cero todos los valores...
unsigned int PdsSnNatural
Definition: pdssnglobal.h:60
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