ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "TMVA/Types.h"
60 
61 
63  fLINEAR("linear"),
64  fSIGMOID("sigmoid"),
65  fTANH("tanh"),
66  fRELU("ReLU"),
67  fRADIAL("radial"),
68  fLogger( new MsgLogger("TActivationChooser") )
69 {
70  // defaut constructor
71 }
72 
74 {
75  // destructor
76  delete fLogger;
77 }
78 
81 {
82  // instantiate the correct activation object according to the
83  // type choosen (given as the enumeration type)
84 
85  switch (type) {
86  case kLinear: return new TActivationIdentity();
87  case kSigmoid: return new TActivationSigmoid();
88  case kTanh: return new TActivationTanh();
89  case kReLU: return new TActivationReLU();
90  case kRadial: return new TActivationRadial();
91  default:
92  Log() << kFATAL << "no Activation function of type " << type << " found" << Endl;
93  return 0;
94  }
95  return NULL;
96 }
97 
100 {
101  // instantiate the correct activation object according to the
102  // type choosen (given by a TString)
103 
104  if (type == fLINEAR) return CreateActivation(kLinear);
105  else if (type == fSIGMOID) return CreateActivation(kSigmoid);
106  else if (type == fTANH) return CreateActivation(kTanh);
107  else if (type == fRELU) return CreateActivation(kReLU);
108  else if (type == fRADIAL) return CreateActivation(kRadial);
109  else {
110  Log() << kFATAL << "no Activation function of type " << type << " found" << Endl;
111  return 0;
112  }
113 }
114 
115 std::vector<TString>*
117 {
118  // retuns the names of all know activation functions
119 
120  std::vector<TString>* names = new std::vector<TString>();
121  names->push_back(fLINEAR);
122  names->push_back(fSIGMOID);
123  names->push_back(fTANH);
124  names->push_back(fRELU);
125  names->push_back(fRADIAL);
126  return names;
127 }
128 
129 
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