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