00001 // @(#)root/tmva $Id: TActivationChooser.cxx 29210 2009-06-25 10:44:35Z brun $ 00002 // Author: Matt Jachowski 00003 00004 /********************************************************************************** 00005 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * 00006 * Package: TMVA * 00007 * Class : TMVA::TActivationChooser * 00008 * Web : http://tmva.sourceforge.net * 00009 * * 00010 * Description: * 00011 * Class for easily choosing activation functions. * 00012 * * 00013 * Authors (alphabetical): * 00014 * Matt Jachowski <jachowski@stanford.edu> - Stanford University, USA * 00015 * * 00016 * Copyright (c) 2005: * 00017 * CERN, Switzerland * 00018 * * 00019 * Redistribution and use in source and binary forms, with or without * 00020 * modification, are permitted according to the terms listed in LICENSE * 00021 * (http://tmva.sourceforge.net/LICENSE) * 00022 **********************************************************************************/ 00023 00024 #include "TMVA/TActivationChooser.h" 00025 00026 00027 ////////////////////////////////////////////////////////////////////////// 00028 // // 00029 // TActivationChooser // 00030 // // 00031 // Class for easily choosing activation functions // 00032 // // 00033 ////////////////////////////////////////////////////////////////////////// 00034 00035 #include <vector> 00036 #include "TString.h" 00037 00038 #ifndef ROOT_TMVA_TActivation 00039 #include "TMVA/TActivation.h" 00040 #endif 00041 #ifndef ROOT_TMVA_TActivationIdentity 00042 #include "TMVA/TActivationIdentity.h" 00043 #endif 00044 #ifndef ROOT_TMVA_TActivationSigmoid 00045 #include "TMVA/TActivationSigmoid.h" 00046 #endif 00047 #ifndef ROOT_TMVA_TActivationTanh 00048 #include "TMVA/TActivationTanh.h" 00049 #endif 00050 #ifndef ROOT_TMVA_TActivationRadial 00051 #include "TMVA/TActivationRadial.h" 00052 #endif 00053 #ifndef ROOT_TMVA_MsgLogger 00054 #include "TMVA/MsgLogger.h" 00055 #endif 00056 00057 00058 TMVA::TActivationChooser::TActivationChooser() : 00059 fLINEAR("linear"), 00060 fSIGMOID("sigmoid"), 00061 fTANH("tanh"), 00062 fRADIAL("radial"), 00063 fLogger( new MsgLogger("TActivationChooser") ) 00064 { 00065 // defaut constructor 00066 } 00067 00068 TMVA::TActivationChooser::~TActivationChooser() 00069 { 00070 // destructor 00071 delete fLogger; 00072 } 00073 00074 TMVA::TActivation* 00075 TMVA::TActivationChooser::CreateActivation(EActivationType type) const 00076 { 00077 // instantiate the correct activation object according to the 00078 // type choosen (given as the enumeration type) 00079 00080 switch (type) { 00081 case kLinear: return new TActivationIdentity(); 00082 case kSigmoid: return new TActivationSigmoid(); 00083 case kTanh: return new TActivationTanh(); 00084 case kRadial: return new TActivationRadial(); 00085 default: 00086 Log() << kFATAL << "no Activation function of type " << type << " found" << Endl; 00087 return 0; 00088 } 00089 return NULL; 00090 } 00091 00092 TMVA::TActivation* 00093 TMVA::TActivationChooser::CreateActivation(const TString& type) const 00094 { 00095 // instantiate the correct activation object according to the 00096 // type choosen (given by a TString) 00097 00098 if (type == fLINEAR) return CreateActivation(kLinear); 00099 else if (type == fSIGMOID) return CreateActivation(kSigmoid); 00100 else if (type == fTANH) return CreateActivation(kTanh); 00101 else if (type == fRADIAL) return CreateActivation(kRadial); 00102 else { 00103 Log() << kFATAL << "no Activation function of type " << type << " found" << Endl; 00104 return 0; 00105 } 00106 } 00107 00108 std::vector<TString>* 00109 TMVA::TActivationChooser::GetAllActivationNames() const 00110 { 00111 // retuns the names of all know activation functions 00112 00113 std::vector<TString>* names = new std::vector<TString>(); 00114 names->push_back(fLINEAR); 00115 names->push_back(fSIGMOID); 00116 names->push_back(fTANH); 00117 names->push_back(fRADIAL); 00118 return names; 00119 } 00120 00121