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