#include <iostream>
#include "TFormula.h"
#include "TString.h"
#include "TMath.h"
#include "Riostream.h"
#include "TMVA/TActivationSigmoid.h"
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 << "{" << std::endl;
fout << " // sigmoid" << std::endl;
fout << " return 1.0/(1.0+exp(-x));" << std::endl;
fout << "}" << std::endl;
fout << " " << std::endl;
}
Last change: Wed Jun 25 08:48:50 2008
Last generated: 2008-06-25 08:48
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.