Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TActivationSigmoid.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 : TActivationSigmoid *
8 * *
9 * *
10 * Description: *
11 * Sigmoid activation function for TNeuron *
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 * (see tmva/doc/LICENSE) *
22 **********************************************************************************/
23
24/*! \class TMVA::TActivationSigmoid
25\ingroup TMVA
26Sigmoid activation function for TNeuron.
27*/
28
30
31#include "TMVA/TActivation.h"
32
33#include "TMath.h"
34#include "TString.h"
35
36#include <iostream>
37
38
40
41////////////////////////////////////////////////////////////////////////////////
42/// evaluate the sigmoid
43
45{
46 return 1.0 / (1.0 + TMath::Exp(-arg));
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// evaluate the derivative of the sigmoid
51
53{
54 Double_t tmp = (1.0 + TMath::Exp(-arg));
55 return TMath::Exp(-arg) / (tmp * tmp);
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// get expressions for the sigmoid and its derivatives
60
62{
63 TString expr = "1.0/(1.0+TMath::Exp(-x))\t\tTMath::Exp(-x)/(1.0+TMath::Exp(-x))^2";
64 return expr;
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// writes the sigmoid activation function source code
69
70void TMVA::TActivationSigmoid::MakeFunction( std::ostream& fout, const TString& fncName )
71{
72 fout << "double " << fncName << "(double x) const {" << std::endl;
73 fout << " // sigmoid" << std::endl;
74 fout << " return 1.0/(1.0+exp(-x));" << std::endl;
75 fout << "}" << std::endl;
76}
#define ClassImp(name)
Definition Rtypes.h:382
Sigmoid activation function for TNeuron.
TString GetExpression()
get expressions for the sigmoid and its derivatives
Double_t Eval(Double_t arg)
evaluate the sigmoid
Double_t EvalDerivative(Double_t arg)
evaluate the derivative of the sigmoid
virtual void MakeFunction(std::ostream &fout, const TString &fncName)
writes the sigmoid activation function source code
Basic string class.
Definition TString.h:139
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Definition TMath.h:713