Logo ROOT   6.12/07
Reference Guide
TSynapse.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 : TSynapse *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation (see header for description) *
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::TSynapse
25 \ingroup TMVA
26 Synapse class used by TMVA artificial neural network methods
27 */
28 
29 #include "TMVA/TSynapse.h"
30 
31 #include "TMVA/TNeuron.h"
32 
33 #include "TMVA/MsgLogger.h"
34 
35 #include "TMVA/Types.h"
36 
37 #include "ThreadLocalStorage.h"
38 #include "TObject.h"
39 
40 static const Int_t fgUNINITIALIZED = -1;
41 
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// constructor
46 
48  : fWeight( 0 ),
49  fLearnRate( 0 ),
50  fDelta( 0 ),
51  fDEDw( 0 ),
52  fCount( 0 ),
53  fPreNeuron( NULL ),
54  fPostNeuron( NULL )
55 {
57 }
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// destructor
61 
63 {
64 }
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// set synapse weight
68 
70 {
71  fWeight = weight;
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// get output of pre-neuron weighted by synapse weight
76 
78 {
79  if (fPreNeuron == NULL)
80  Log() << kFATAL << "<GetWeightedValue> synapse not connected to neuron" << Endl;
81 
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 /// get error field of post-neuron weighted by synapse weight
87 
89 {
90  if (fPostNeuron == NULL)
91  Log() << kFATAL << "<GetWeightedDelta> synapse not connected to neuron" << Endl;
92 
93  return fWeight * fPostNeuron->GetDelta();
94 }
95 
96 ////////////////////////////////////////////////////////////////////////////////
97 /// adjust the weight based on the error field all ready calculated by CalculateDelta
98 
100 {
101  Double_t wDelta = fDelta / fCount;
102  fWeight += -fLearnRate * wDelta;
103  InitDelta();
104 }
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// calculate/adjust the error field for this synapse
108 
110 {
112  fCount++;
113 }
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 
118 {
119  TTHREAD_TLS_DECL_ARG(MsgLogger,logger,"TSynapse"); //! message logger, static to save resources
120  return logger;
121 }
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:158
Int_t fCount
Definition: TSynapse.h:97
Synapse class used by TMVA artificial neural network methods.
Definition: TSynapse.h:44
int Int_t
Definition: RtypesCore.h:41
Double_t GetActivationValue() const
Definition: TNeuron.h:105
TNeuron * fPostNeuron
Definition: TSynapse.h:99
Double_t fWeight
Definition: TSynapse.h:93
void AdjustWeight()
adjust the weight based on the error field all ready calculated by CalculateDelta ...
Definition: TSynapse.cxx:99
void SetWeight(Double_t weight)
set synapse weight
Definition: TSynapse.cxx:69
Double_t GetWeightedDelta()
get error field of post-neuron weighted by synapse weight
Definition: TSynapse.cxx:88
Double_t GetDelta() const
Definition: TNeuron.h:106
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
void InitDelta()
Definition: TSynapse.h:85
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
virtual ~TSynapse()
destructor
Definition: TSynapse.cxx:62
void CalculateDelta()
calculate/adjust the error field for this synapse
Definition: TSynapse.cxx:109
TSynapse()
constructor
Definition: TSynapse.cxx:47
Double_t fLearnRate
Definition: TSynapse.h:94
TNeuron * fPreNeuron
Definition: TSynapse.h:98
Double_t GetWeightedValue()
get output of pre-neuron weighted by synapse weight
Definition: TSynapse.cxx:77
static const Int_t fgUNINITIALIZED
Definition: TSynapse.cxx:40
Double_t fDelta
Definition: TSynapse.h:95
MsgLogger & Log() const
Definition: TSynapse.cxx:117