ROOT  6.06/09
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 //_______________________________________________________________________
25 //
26 // Radial basis activation function for ANN. This really simple implementation
27 // uses TFormulas and should probably be replaced with something more
28 // efficient later.
29 //_______________________________________________________________________
30 
31 #include <iostream>
32 
33 #include "TFormula.h"
34 #include "TString.h"
35 #include "TMath.h"
36 
37 #ifndef ROOT_TMVA_TActivationRadial
38 #include "TMVA/TActivationRadial.h"
39 #endif
40 
41 static const Int_t UNINITIALIZED = -1;
42 
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// constructor for gaussian with center 0, width 1
47 
48 TMVA::TActivationRadial::TActivationRadial()
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 }
ClassImp(TMVA::TActivationRadial) TMVA
constructor for gaussian with center 0, width 1
Double_t Eval(Double_t arg)
evaluate gaussian
Basic string class.
Definition: TString.h:137
virtual void MakeFunction(std::ostream &fout, const TString &fncName)
writes the sigmoid activation function source code
int Int_t
Definition: RtypesCore.h:41
TString GetExpression()
get expressions for the gaussian and its derivatives
The F O R M U L A class.
Definition: TFormula.h:89
Double_t EvalDerivative(Double_t arg)
evaluate derivative
double Double_t
Definition: RtypesCore.h:55
Abstract ClassifierFactory template that handles arbitrary types.
static const Int_t UNINITIALIZED
#define NULL
Definition: Rtypes.h:82