#include <Pds/Ra>
#include <Pds/Nn>
#include <iomanip>
int main(void)
{
unsigned int M=40;
double Acc=0;
Pds::Matrix IMGA1=Pds::Matrix::ImportBmpFileAsGray("../manual/imagenes/happy.bmp");
Pds::Matrix IMGA2=Pds::Matrix::ImportBmpFileAsGray("../manual/imagenes/sad.bmp");
Pds::Matrix IMGB1=Pds::Matrix::ImportBmpFileAsGray("../manual/imagenes/self-confidence.bmp");
Pds::Matrix IMGB2=Pds::Matrix::ImportBmpFileAsGray("../manual/imagenes/fear.bmp");
Pds::Matrix IMGC0=Pds::Matrix::ImportBmpFileAsGray("../manual/imagenes/pokerface.bmp");
unsigned int Nlin=IMGA1.Nlin();
unsigned int Ncol=IMGA1.Ncol();
Pds::Matrix Y(5,Nlin*Ncol);
Y.SetRowVector(0,Pds::Vector(IMGA1));
Y.SetRowVector(1,Pds::Vector(IMGA2));
Y.SetRowVector(2,Pds::Vector(IMGB1));
Y.SetRowVector(3,Pds::Vector(IMGB2));
Y.SetRowVector(4,Pds::Vector(IMGC0));
Y=Y.Geq(127);
Pds::Matrix Ys(Y.Size());
Pds::Matrix X= " 0.0 1.0\n"
" 0.0 -1.0\n"
" 1.0 0.0\n"
"-1.0 0.0\n"
" 0.0 0.0";
std::cout<<"Ninputs:"<<X.Ncol()<<std::endl;
std::cout<<"Noutputs:"<<Y.Ncol()<<std::endl;
std::vector<unsigned int> N={X.Ncol(),4096,2048,Y.Ncol()};
for(unsigned int k=0;(k<M)&&(Acc<1.0);k++)
{
Acc=Pds::Accuracy(Ys.Geq(0.5),Y);
std::cout<<"Test["<<std::setw(3)<<k<<"] ";
std::cout<<"Accuracy %: "<<100.0*Acc<<std::endl;
}
X=Pds::Matrix(1,X.Ncol()); Ys=Pds::Matrix(1,Y.Ncol());
std::vector<Pds::Matrix> Block;
Pds::Matrix IMG;
for(unsigned int k=0;k<360;k=k+5)
{
X.Set( 0, cos(k*Pds::Ra::Pi/180.0) );
X.Set( 1, sin(k*Pds::Ra::Pi/180.0) );
IMG=Ys.Remodel(Nlin,Ncol)*255;
Block.push_back(IMG);
}
Pds::Matrix::ExportAsGif(Block,"smiles.gif",20);
return 0;
}
La clase tipo Pds::FCNn . Esta clase genera un objeto con dos parametros Nlin y Ncol....
const std::string FCNn
Tag de un objeto de tipo Pds::FCNn.
bool Training(const Pds::Matrix &X, const Pds::Matrix &Y, double alpha, double lambda)
Treina la NN como um bloque de datos entero X para encontrar una variacion de pesos.
Pds::SampleBlock Predict(const Pds::SampleBlock &In) const
Evalua la capa de la CNN.