Logo ROOT  
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 }
TActivationRadial.h
TMath::Log
Double_t Log(Double_t x)
Definition: TMath.h:760
TMVA::TActivationIdentity
Identity activation function for TNeuron.
Definition: TActivationIdentity.h:41
TMVA::TActivationChooser::CreateActivation
TActivation * CreateActivation(EActivationType type) const
instantiate the correct activation object according to the type chosen (given as the enumeration type...
Definition: TActivationChooser.cxx:70
TMVA::TActivationTanh
Tanh activation function for ANN.
Definition: TActivationTanh.h:41
TActivationReLU.h
TMVA::TActivation
Interface for TNeuron activation function classes.
Definition: TActivation.h:42
TMVA::TActivationChooser::EActivationType
EActivationType
Definition: TActivationChooser.h:47
TMVA::DNN::EActivationFunction::kTanh
@ kTanh
TMVA::TActivationReLU
Rectified Linear Unit activation function for TNeuron.
Definition: TActivationReLU.h:41
TString
Basic string class.
Definition: TString.h:136
TString.h
TMVA::TActivationSigmoid
Sigmoid activation function for TNeuron.
Definition: TActivationSigmoid.h:41
TActivation.h
MsgLogger.h
TMVA::TActivationChooser::TActivationChooser
TActivationChooser()
Default constructor.
Definition: TActivationChooser.cxx:47
Types.h
TMVA::Endl
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:158
TMVA::MsgLogger
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
TMVA::TActivationRadial
Radial basis activation function for ANN.
Definition: TActivationRadial.h:41
TActivationChooser.h
TMVA::TActivationChooser::GetAllActivationNames
std::vector< TString > * GetAllActivationNames() const
returns the names of all know activation functions
Definition: TActivationChooser.cxx:107
TActivationTanh.h
TMVA::DNN::EActivationFunction::kSigmoid
@ kSigmoid
type
int type
Definition: TGX11.cxx:121
TActivationIdentity.h
TMVA::TActivationChooser::~TActivationChooser
virtual ~TActivationChooser()
Destructor.
Definition: TActivationChooser.cxx:60
TActivationSigmoid.h