Logo ROOT  
Reference Guide
TActivationReLU.cxx
Go to the documentation of this file.
1// @(#)root/tmva $Id$
2// Author: Helge Voss
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6 * Package: TMVA *
7 * Class : TActivationReLU *
8 * Web : http://tmva.sourceforge.net *
9 * *
10 * Description: *
11 * Rectified linear unit function for an ANN. *
12 * *
13 * Authors (alphabetical): *
14 * Helge Voss *
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::TActivationReLU
25\ingroup TMVA
26Rectified Linear Unit 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
39
40////////////////////////////////////////////////////////////////////////////////
41/// get expressions for the tanh and its derivative
42
44{
45 TString expr = "max(0,x)";
46
47 return expr;
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// writes the Rectified Linear Unit activation function source code
52
53void TMVA::TActivationReLU::MakeFunction( std::ostream& fout, const TString& fncName )
54{
55 fout << "double " << fncName << "(double x) const {" << std::endl;
56 fout << " // rectified linear unit" << std::endl;
57 fout << " return x>0 ? x : 0; " << std::endl;
58 fout << "}" << std::endl;
59}
#define ClassImp(name)
Definition: Rtypes.h:365
Rectified Linear Unit activation function for TNeuron.
virtual void MakeFunction(std::ostream &fout, const TString &fncName)
writes the Rectified Linear Unit activation function source code
TString GetExpression()
get expressions for the tanh and its derivative
Basic string class.
Definition: TString.h:131