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
39
40////////////////////////////////////////////////////////////////////////////////
41/// evaluate the sigmoid
42
44{
45 return 1.0 / (1.0 + TMath::Exp(-arg));
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// evaluate the derivative of the sigmoid
50
52{
53 Double_t tmp = (1.0 + TMath::Exp(-arg));
54 return TMath::Exp(-arg) / (tmp * tmp);
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// get expressions for the sigmoid and its derivatives
59
61{
62 TString expr = "1.0/(1.0+TMath::Exp(-x))\t\tTMath::Exp(-x)/(1.0+TMath::Exp(-x))^2";
63 return expr;
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// writes the sigmoid activation function source code
68
70{
71 fout << "double " << fncName << "(double x) const {" << std::endl;
72 fout << " // sigmoid" << std::endl;
73 fout << " return 1.0/(1.0+exp(-x));" << std::endl;
74 fout << "}" << std::endl;
75}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void MakeFunction(std::ostream &fout, const TString &fncName) override
writes the sigmoid activation function source code
Double_t EvalDerivative(Double_t arg) override
evaluate the derivative of the sigmoid
Double_t Eval(Double_t arg) override
evaluate the sigmoid
TString GetExpression() override
get expressions for the sigmoid and its derivatives
Basic string class.
Definition TString.h:138
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:720