Home | Develop | Download | Contact
example_fclayer_export.cpp

Programa para el testeo de las funciones Fully Connected Layer.Para compilar o código example_fclayer_export.cpp:

g++ -static -o example_fclayer_export example_fclayer_export.cpp -lpdsramm -lpdsnnmm

Para executar o programa:

./example_fclayer_export

Retornando por consola:

L1:
     Nin: 3
    Nout: 2
 ActFunc: Pds::Tanh
DActFunc: Pds::DTanh
       W: 
0.53763086114909        0.36954202465847        0.56382463392773        -0.87250749271152
-0.22063468437125       -1.3938059648353        -0.7925277058445        2.1272209970701

L2:
     Nin: 3
    Nout: 2
 ActFunc: Pds::Tanh
DActFunc: Pds::DTanh
       W: 
0.53763086114909        0.36954202465847        0.56382463392773        -0.87250749271152
-0.22063468437125       -1.3938059648353        -0.7925277058445        2.1272209970701

Código example_fclayer_export.cpp:

#include <Pds/Ra>
#include <Pds/Nn>
int main(void)
{
// Creating the layer with random init
Pds::FCLayer L1=Pds::FCLayer(3,2,Pds::Tanh,Pds::DTanh);
L1.PrintStylized("\nL1:\n");
// Save layer in file
std::ofstream myfile;
myfile.open("filedat1.txt");
L1.SaveInStream(myfile);
myfile.close();
// Creating empty layer
// Load layer from file
std::ifstream ifs("filedat1.txt", std::ifstream::in);
Pds::Nn::DefaultActFunc =Pds::Sigmoid;
Pds::Nn::DefaultDActFunc=Pds::DSigmoid;
L2.LoadFromStream(ifs);
ifs.close();
L2.PrintStylized("\nL2:\n");
Pds::FCLayer L3=Pds::FCLayer(2,3,Pds::Tanh,Pds::DTanh);
myfile.open("FCLayer.xml");
L3.ExportXmlToStream(myfile);
myfile.close();
return 0;
}
La clase tipo Pds::FCLayer . Esta clase genera un objeto con dos parametros Nlin y Ncol....
Definition: FCLayer.hpp:61
const std::string FCLayer
Tag de un objeto de tipo Pds::FCLayer.
Definition: NnDefines.hpp:149
double(* DefaultDActFunc)(double)
double(* DefaultActFunc)(double)
bool ExportXmlToStream(std::ofstream &myfile) const
Salva los datos de la capa en un std::ofstream en formato Xml.
void PrintStylized(std::string str="") const
Muestra en pantalla el contenido de Pds::FCLayer, en el formato (Nli,Ncol).
bool LoadFromStream(std::ifstream &ifs)
Carga los datos de la capa.
bool SaveInStream(std::ofstream &myfile) const
Salva los datos de la capa.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed