Home | Develop | Download | Contact
test_fcnn_training2.cpp
1 #include <Pds/Ra>
2 #include <Pds/Nn>
3 #include "extras.h"
4 
5 int main(void)
6 {
7  unsigned int M=2000;
8  Pds::Vector Acc(M);
9 
10  Pds::Matrix X(Pds::Ra::TextFormat,"../test/data_x_yinyang.txt");
11  Pds::Matrix Y(Pds::Ra::TextFormat,"../test/data_y_yinyang.txt");
12  Pds::Matrix Ys(Y.Size());
13 
14  std::vector<unsigned int> N={2,512,64,8,1};
15  Pds::FCNn NN0=Pds::FCNn(N,Pds::Sigmoid,Pds::DSigmoid);
16 
17  Pds::Matrix Xtr=X;
18  Pds::Matrix Ytr=Y;
19  Pds::Vector T;
20 
21  Pds::Ra::Tic();
22  for(unsigned int k=0;k<M;k++)
23  {
24  NN0.Training(Xtr,Ytr,0.1,0.01);
25 
26  NN0.Evaluate(X,Ys);
27 
28  Acc.Set(k,100.0*Pds::Accuracy(Ys.Geq(0.5),Y));
29  std::cout<<"Test["<<k<<"]\t";
30  std::cout<<"Accuracy %: "<<Acc.At(k)<<std::endl;
31 
32  T=Ys.Geq(0.5).NotEqualTo(Y);
33  Xtr=X.FindRows(T);
34  Ytr=Y.FindRows(T);
35  }
36  Pds::Ra::Toc();
37 
38  pds_octave_plot_points(Pds::LinSpace(0,M-1,M),Acc,"Iter","Accuracy","testando.m","test_fcnn_training2_Acc.png");
39  pds_octave_plot_vector(X,Y ,"x_1","x_2","testando.m","test_fcnn_training2_Y.png");
40  pds_octave_plot_vector(X,Ys,"x_1","x_2","testando.m","test_fcnn_training2_Ys.png");
41 
42  NN0.Save("../test/NeuralNettwork1.txt");
43  return 0;
44 }
La clase tipo Pds::FCNn . Esta clase genera un objeto con dos parametros Nlin y Ncol....
Definition: FCNn.hpp:61
bool Training(const Pds::Matrix &X, const Pds::Matrix &Y, double alpha, double lambda)
Treina la CNN.
Pds::Vector Evaluate(const Pds::Vector &In)
Evalua la capa de la CNN.
bool Save(std::string filename)
Salva los datos en un archivo binario.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed