ROOT  6.06/09
Reference Guide
TActivationChooser.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 : TMVA::TActivationChooser *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Class for easily choosing activation functions. *
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 
25 
26 
27 //////////////////////////////////////////////////////////////////////////
28 // //
29 // TActivationChooser //
30 // //
31 // Class for easily choosing activation functions //
32 // //
33 //////////////////////////////////////////////////////////////////////////
34 
35 #include <vector>
36 #include "TString.h"
37 
38 #ifndef ROOT_TMVA_TActivation
39 #include "TMVA/TActivation.h"
40 #endif
41 #ifndef ROOT_TMVA_TActivationIdentity
43 #endif
44 #ifndef ROOT_TMVA_TActivationSigmoid
46 #endif
47 #ifndef ROOT_TMVA_TActivationTanh
48 #include "TMVA/TActivationTanh.h"
49 #endif
50 #ifndef ROOT_TMVA_TActivationReLU
51 #include "TMVA/TActivationReLU.h"
52 #endif
53 #ifndef ROOT_TMVA_TActivationRadial
54 #include "TMVA/TActivationRadial.h"
55 #endif
56 #ifndef ROOT_TMVA_MsgLogger
57 #include "TMVA/MsgLogger.h"
58 #endif
59 
60 
62  fLINEAR("linear"),
63  fSIGMOID("sigmoid"),
64  fTANH("tanh"),
65  fRELU("ReLU"),
66  fRADIAL("radial"),
67  fLogger( new MsgLogger("TActivationChooser") )
68 {
69  // defaut constructor
70 }
71 
73 {
74  // destructor
75  delete fLogger;
76 }
77 
80 {
81  // instantiate the correct activation object according to the
82  // type choosen (given as the enumeration type)
83 
84  switch (type) {
85  case kLinear: return new TActivationIdentity();
86  case kSigmoid: return new TActivationSigmoid();
87  case kTanh: return new TActivationTanh();
88  case kReLU: return new TActivationReLU();
89  case kRadial: return new TActivationRadial();
90  default:
91  Log() << kFATAL << "no Activation function of type " << type << " found" << Endl;
92  return 0;
93  }
94  return NULL;
95 }
96 
99 {
100  // instantiate the correct activation object according to the
101  // type choosen (given by a TString)
102 
103  if (type == fLINEAR) return CreateActivation(kLinear);
104  else if (type == fSIGMOID) return CreateActivation(kSigmoid);
105  else if (type == fTANH) return CreateActivation(kTanh);
106  else if (type == fRELU) return CreateActivation(kReLU);
107  else if (type == fRADIAL) return CreateActivation(kRadial);
108  else {
109  Log() << kFATAL << "no Activation function of type " << type << " found" << Endl;
110  return 0;
111  }
112 }
113 
114 std::vector<TString>*
116 {
117  // retuns the names of all know activation functions
118 
119  std::vector<TString>* names = new std::vector<TString>();
120  names->push_back(fLINEAR);
121  names->push_back(fSIGMOID);
122  names->push_back(fTANH);
123  names->push_back(fRELU);
124  names->push_back(fRADIAL);
125  return names;
126 }
127 
128 
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:162
Basic string class.
Definition: TString.h:137
TActivation * CreateActivation(EActivationType type) const
int type
Definition: TGX11.cxx:120
std::vector< TString > * GetAllActivationNames() const
#define NULL
Definition: Rtypes.h:82
Definition: math.cpp:60