Logo ROOT   6.12/07
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 
24 /*! \class TMVA::TActivationChooser
25 \ingroup TMVA
26 Class for easily choosing activation functions
27 */
28 
30 
31 #include <vector>
32 #include "TString.h"
33 
34 #include "TMVA/TActivation.h"
37 #include "TMVA/TActivationTanh.h"
38 #include "TMVA/TActivationReLU.h"
39 #include "TMVA/TActivationRadial.h"
40 #include "TMVA/MsgLogger.h"
41 #include "TMVA/Types.h"
42 
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// Default constructor.
46 
48  fLINEAR("linear"),
49  fSIGMOID("sigmoid"),
50  fTANH("tanh"),
51  fRELU("ReLU"),
52  fRADIAL("radial"),
53  fLogger( new MsgLogger("TActivationChooser") )
54 {
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Destructor.
59 
61 {
62  delete fLogger;
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// instantiate the correct activation object according to the
67 /// type chosen (given as the enumeration type)
68 
71 {
72  switch (type) {
73  case kLinear: return new TActivationIdentity();
74  case kSigmoid: return new TActivationSigmoid();
75  case kTanh: return new TActivationTanh();
76  case kReLU: return new TActivationReLU();
77  case kRadial: return new TActivationRadial();
78  default:
79  Log() << kFATAL << "no Activation function of type " << type << " found" << Endl;
80  return 0;
81  }
82  return NULL;
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 /// instantiate the correct activation object according to the
87 /// type chosen (given by a TString)
88 
91 {
92  if (type == fLINEAR) return CreateActivation(kLinear);
93  else if (type == fSIGMOID) return CreateActivation(kSigmoid);
94  else if (type == fTANH) return CreateActivation(kTanh);
95  else if (type == fRELU) return CreateActivation(kReLU);
96  else if (type == fRADIAL) return CreateActivation(kRadial);
97  else {
98  Log() << kFATAL << "no Activation function of type " << type << " found" << Endl;
99  return 0;
100  }
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// returns the names of all know activation functions
105 
106 std::vector<TString>*
108 {
109  std::vector<TString>* names = new std::vector<TString>();
110  names->push_back(fLINEAR);
111  names->push_back(fSIGMOID);
112  names->push_back(fTANH);
113  names->push_back(fRELU);
114  names->push_back(fRADIAL);
115  return names;
116 }
Radial basis activation function for ANN.
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:158
Basic string class.
Definition: TString.h:125
MsgLogger & Log() const
message logger
Sigmoid activation function for TNeuron.
TActivation * CreateActivation(EActivationType type) const
instantiate the correct activation object according to the type chosen (given as the enumeration type...
virtual ~TActivationChooser()
Destructor.
Tanh activation function for ANN.
Identity activation function for TNeuron.
Rectified Linear Unit activation function for TNeuron.
TActivationChooser()
Default constructor.
int type
Definition: TGX11.cxx:120
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
std::vector< TString > * GetAllActivationNames() const
returns the names of all know activation functions
Interface for TNeuron activation function classes.
Definition: TActivation.h:42