#include <iostream>
#include "TFormula.h"
#include "TString.h"
#include "TMath.h"
#ifndef ROOT_TMVA_TActivationSigmoid
#include "TMVA/TActivationSigmoid.h"
#endif
static const Int_t UNINITIALIZED = -1;
ClassImp(TMVA::TActivationSigmoid)
TMVA::TActivationSigmoid::TActivationSigmoid()
{
fEqn = new TFormula("sigmoid", "1.0/(1.0+TMath::Exp(-x))");
fEqnDerivative =
new TFormula("derivative", "TMath::Exp(-x)/(1.0+TMath::Exp(-x))^2");
}
TMVA::TActivationSigmoid::~TActivationSigmoid()
{
if (fEqn != NULL) delete fEqn;
if (fEqnDerivative != NULL) delete fEqnDerivative;
}
Double_t TMVA::TActivationSigmoid::Eval(Double_t arg)
{
if (fEqn == NULL) return UNINITIALIZED;
return fEqn->Eval(arg);
}
Double_t TMVA::TActivationSigmoid::EvalDerivative(Double_t arg)
{
if (fEqnDerivative == NULL) return UNINITIALIZED;
return fEqnDerivative->Eval(arg);
}
TString TMVA::TActivationSigmoid::GetExpression()
{
TString expr = "";
if (fEqn == NULL) expr += "<null>";
else expr += fEqn->GetExpFormula();
expr += "\t\t";
if (fEqnDerivative == NULL) expr += "<null>";
else expr += fEqnDerivative->GetExpFormula();
return expr;
}
void TMVA::TActivationSigmoid::MakeFunction( std::ostream& fout, const TString& fncName )
{
fout << "double " << fncName << "(double x) const {" << std::endl;
fout << " // sigmoid" << std::endl;
fout << " return 1.0/(1.0+exp(-x));" << std::endl;
fout << "}" << std::endl;
}
TActivationSigmoid.cxx:10 TActivationSigmoid.cxx:11 TActivationSigmoid.cxx:12 TActivationSigmoid.cxx:13 TActivationSigmoid.cxx:14 TActivationSigmoid.cxx:15 TActivationSigmoid.cxx:16 TActivationSigmoid.cxx:17 TActivationSigmoid.cxx:18 TActivationSigmoid.cxx:19 TActivationSigmoid.cxx:20 TActivationSigmoid.cxx:21 TActivationSigmoid.cxx:22 TActivationSigmoid.cxx:23 TActivationSigmoid.cxx:24 TActivationSigmoid.cxx:25 TActivationSigmoid.cxx:26 TActivationSigmoid.cxx:27 TActivationSigmoid.cxx:28 TActivationSigmoid.cxx:29 TActivationSigmoid.cxx:30 TActivationSigmoid.cxx:31 TActivationSigmoid.cxx:32 TActivationSigmoid.cxx:33 TActivationSigmoid.cxx:34 TActivationSigmoid.cxx:35 TActivationSigmoid.cxx:36 TActivationSigmoid.cxx:37 TActivationSigmoid.cxx:38 TActivationSigmoid.cxx:39 TActivationSigmoid.cxx:40 TActivationSigmoid.cxx:41 TActivationSigmoid.cxx:42 TActivationSigmoid.cxx:43 TActivationSigmoid.cxx:44 TActivationSigmoid.cxx:45 TActivationSigmoid.cxx:46 TActivationSigmoid.cxx:47 TActivationSigmoid.cxx:48 TActivationSigmoid.cxx:49 TActivationSigmoid.cxx:50 TActivationSigmoid.cxx:51 TActivationSigmoid.cxx:52 TActivationSigmoid.cxx:53 TActivationSigmoid.cxx:54 TActivationSigmoid.cxx:55 TActivationSigmoid.cxx:56 TActivationSigmoid.cxx:57 TActivationSigmoid.cxx:58 TActivationSigmoid.cxx:59 TActivationSigmoid.cxx:60 TActivationSigmoid.cxx:61 TActivationSigmoid.cxx:62 TActivationSigmoid.cxx:63 TActivationSigmoid.cxx:64 TActivationSigmoid.cxx:65 TActivationSigmoid.cxx:66 TActivationSigmoid.cxx:67 TActivationSigmoid.cxx:68 TActivationSigmoid.cxx:69 TActivationSigmoid.cxx:70 TActivationSigmoid.cxx:71 TActivationSigmoid.cxx:72 TActivationSigmoid.cxx:73 TActivationSigmoid.cxx:74 TActivationSigmoid.cxx:75 TActivationSigmoid.cxx:76 TActivationSigmoid.cxx:77 TActivationSigmoid.cxx:78 TActivationSigmoid.cxx:79 TActivationSigmoid.cxx:80 TActivationSigmoid.cxx:81 TActivationSigmoid.cxx:82 TActivationSigmoid.cxx:83 TActivationSigmoid.cxx:84 TActivationSigmoid.cxx:85 TActivationSigmoid.cxx:86 TActivationSigmoid.cxx:87 TActivationSigmoid.cxx:88 TActivationSigmoid.cxx:89 TActivationSigmoid.cxx:90 TActivationSigmoid.cxx:91 TActivationSigmoid.cxx:92 TActivationSigmoid.cxx:93 TActivationSigmoid.cxx:94 TActivationSigmoid.cxx:95 TActivationSigmoid.cxx:96 TActivationSigmoid.cxx:97 TActivationSigmoid.cxx:98 TActivationSigmoid.cxx:99 TActivationSigmoid.cxx:100 TActivationSigmoid.cxx:101 TActivationSigmoid.cxx:102 TActivationSigmoid.cxx:103 TActivationSigmoid.cxx:104 TActivationSigmoid.cxx:105 TActivationSigmoid.cxx:106 TActivationSigmoid.cxx:107 TActivationSigmoid.cxx:108 TActivationSigmoid.cxx:109 TActivationSigmoid.cxx:110 TActivationSigmoid.cxx:111 TActivationSigmoid.cxx:112 TActivationSigmoid.cxx:113