Logo ROOT   6.14/05
Reference Guide
TActivationRadial.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Matt Jachowski
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : TActivationRadial *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Radial basis activation function for TNeuron *
12  * *
13  * Authors (alphabetical): *
14  * Matt Jachowski <jachowski@stanford.edu> - Stanford University, USA *
15  * *
16  * Copyright (c) 2005: *
17  * CERN, Switzerland *
18  * *
19  * Redistribution and use in source and binary forms, with or without *
20  * modification, are permitted according to the terms listed in LICENSE *
21  * (http://tmva.sourceforge.net/LICENSE) *
22  **********************************************************************************/
23 
24 /*! \class TMVA::TActivationRadial
25 \ingroup TMVA
26 Radial basis activation function for ANN. This really simple implementation
27 uses TFormula and should probably be replaced with something more
28 efficient later.
29 */
30 
31 #include "TMVA/TActivationRadial.h"
32 
33 #include "TMVA/TActivation.h"
34 
35 #include "TFormula.h"
36 #include "TMath.h"
37 #include "TString.h"
38 
39 #include <iostream>
40 
41 static const Int_t UNINITIALIZED = -1;
42 
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// constructor for gaussian with center 0, width 1
47 
49 {
50  fEqn = new TFormula("Gaussian", "TMath::Exp(-x^2/2.0)");
51  fEqnDerivative = new TFormula("derivative", "-x*TMath::Exp(-x^2/2.0)");
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// destructor
56 
58 {
59  if (fEqn != NULL) delete fEqn;
60  if (fEqnDerivative != NULL) delete fEqnDerivative;
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// evaluate gaussian
65 
67 {
68  if (fEqn == NULL) return UNINITIALIZED;
69  return fEqn->Eval(arg);
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// evaluate derivative
74 
76 {
77  if (fEqnDerivative == NULL) return UNINITIALIZED;
78  return fEqnDerivative->Eval(arg);
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// get expressions for the gaussian and its derivatives
83 
85 {
86  TString expr = "";
87 
88  if (fEqn == NULL) expr += "<null>";
89  else expr += fEqn->GetExpFormula();
90 
91  expr += "\t\t";
92 
93  if (fEqnDerivative == NULL) expr += "<null>";
94  else expr += fEqnDerivative->GetExpFormula();
95 
96  return expr;
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// writes the sigmoid activation function source code
101 
102 void TMVA::TActivationRadial::MakeFunction( std::ostream& fout, const TString& fncName )
103 {
104  fout << "double " << fncName << "(double x) const {" << std::endl;
105  fout << " // radial" << std::endl;
106  fout << " return exp(-x*x/2.0);" << std::endl;
107  fout << "}" << std::endl;
108 }
Double_t Eval(Double_t x) const
Sets first variable (e.g. x) and evaluate formula.
Definition: TFormula.cxx:3170
Radial basis activation function for ANN.
Double_t Eval(Double_t arg)
evaluate gaussian
Basic string class.
Definition: TString.h:131
virtual void MakeFunction(std::ostream &fout, const TString &fncName)
writes the sigmoid activation function source code
int Int_t
Definition: RtypesCore.h:41
TActivationRadial()
constructor for gaussian with center 0, width 1
TString GetExpression()
get expressions for the gaussian and its derivatives
The Formula class.
Definition: TFormula.h:83
#define ClassImp(name)
Definition: Rtypes.h:359
Double_t EvalDerivative(Double_t arg)
evaluate derivative
double Double_t
Definition: RtypesCore.h:55
TString GetExpFormula(Option_t *option="") const
Return the expression formula.
Definition: TFormula.cxx:3338
static const Int_t UNINITIALIZED