ROOT  6.06/09
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 "ThreadLocalStorage.h"
40 
41 static const Int_t fgUNINITIALIZED = -1;
42 
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// constructor
47 
49  : fWeight( 0 ),
50  fLearnRate( 0 ),
51  fDelta( 0 ),
52  fDEDw( 0 ),
53  fCount( 0 ),
54  fPreNeuron( NULL ),
55  fPostNeuron( NULL )
56 {
58 }
59 
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// destructor
63 
65 {
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// set synapse weight
70 
72 {
73  fWeight = weight;
74 }
75 
76 ////////////////////////////////////////////////////////////////////////////////
77 /// get output of pre-neuron weighted by synapse weight
78 
80 {
81  if (fPreNeuron == NULL)
82  Log() << kFATAL << "<GetWeightedValue> synapse not connected to neuron" << Endl;
83 
84  return (fWeight * fPreNeuron->GetActivationValue());
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// get error field of post-neuron weighted by synapse weight
89 
91 {
92  if (fPostNeuron == NULL)
93  Log() << kFATAL << "<GetWeightedDelta> synapse not connected to neuron" << Endl;
94 
95  return fWeight * fPostNeuron->GetDelta();
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// adjust the weight based on the error field all ready calculated by CalculateDelta
100 
102 {
103  Double_t wDelta = fDelta / fCount;
104  fWeight += -fLearnRate * wDelta;
105  InitDelta();
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// calculate/adjust the error field for this synapse
110 
112 {
113  fDelta += fPostNeuron->GetDelta() * fPreNeuron->GetActivationValue();
114  fCount++;
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 
120 {
121  TTHREAD_TLS_DECL_ARG(MsgLogger,logger,"TSynapse"); //! message logger, static to save resources
122  return logger;
123 }
TSynapse()
constructor
Definition: TSynapse.cxx:48
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:162
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:101
virtual ~TSynapse()
destructor
Definition: TSynapse.cxx:64
void CalculateDelta()
calculate/adjust the error field for this synapse
Definition: TSynapse.cxx:111
Double_t fWeight
Definition: TSynapse.h:97
MsgLogger & Log() const
Definition: TSynapse.cxx:119
ClassImp(TSynapse) TSynapse
Default constructor.
Definition: TSynapse.cxx:27
double Double_t
Definition: RtypesCore.h:55
void SetWeight(Double_t weight)
set synapse weight
Definition: TSynapse.cxx:71
Double_t GetWeightedDelta()
get error field of post-neuron weighted by synapse weight
Definition: TSynapse.cxx:90
Double_t GetWeightedValue()
get output of pre-neuron weighted by synapse weight
Definition: TSynapse.cxx:79
#define NULL
Definition: Rtypes.h:82
static const Int_t fgUNINITIALIZED
Definition: TSynapse.cxx:41
Definition: math.cpp:60