Logo ROOT   6.21/01
Reference Guide
TSynapse.h
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 : TMVA::TSynapse *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Synapse class for use in derivatives of MethodANNBase *
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 #ifndef ROOT_TMVA_TSynapse
25 #define ROOT_TMVA_TSynapse
26 
27 //////////////////////////////////////////////////////////////////////////
28 // //
29 // TSynapse //
30 // //
31 // Synapse used by derivatives of MethodANNBase //
32 // //
33 //////////////////////////////////////////////////////////////////////////
34 
35 #include "TString.h"
36 #include "TFormula.h"
37 
38 
39 namespace TMVA {
40 
41  class TNeuron;
42  class MsgLogger;
43 
44  class TSynapse : public TObject {
45 
46  public:
47 
48  TSynapse();
49  virtual ~TSynapse();
50 
51  // set the weight of the synapse
52  void SetWeight(Double_t weight);
53 
54  // get the weight of the synapse
55  Double_t GetWeight() { return fWeight; }
56 
57  // set the learning rate
58  void SetLearningRate(Double_t rate) { fLearnRate = rate; }
59 
60  // get the learning rate
62 
63  // decay the learning rate
64  void DecayLearningRate(Double_t rate){ fLearnRate *= (1-rate); }
65 
66  // set the pre-neuron
67  void SetPreNeuron(TNeuron* pre) { fPreNeuron = pre; }
68 
69  // set the post-neuron
70  void SetPostNeuron(TNeuron* post) { fPostNeuron = post; }
71 
72  // get the weighted output of the pre-neuron
74 
75  // get the weighted error field of the post-neuron
77 
78  // force the synapse to adjust its weight according to its error field
79  void AdjustWeight();
80 
81  // calculate the error field of the synapse
82  void CalculateDelta();
83 
84  // initialize the error field of the synapse to 0
85  void InitDelta() { fDelta = 0.0; fCount = 0; }
86 
87  void SetDEDw(Double_t DEDw) { fDEDw = DEDw; }
88  Double_t GetDEDw() { return fDEDw; }
89  Double_t GetDelta() { return fDelta; }
90 
91  private:
92 
93  Double_t fWeight; // weight of the synapse
94  Double_t fLearnRate; // learning rate parameter
95  Double_t fDelta; // local error field
96  Double_t fDEDw; // sum of deltas
97  Int_t fCount; // number of updates contributing to error field
98  TNeuron* fPreNeuron; // pointer to pre-neuron
99  TNeuron* fPostNeuron; // pointer to post-neuron
100 
101  MsgLogger& Log() const;
102 
103  ClassDef(TSynapse,0); // Synapse class used by MethodANNBase and derivatives
104  };
105 
106 } // namespace TMVA
107 
108 #endif
Int_t fCount
Definition: TSynapse.h:97
void DecayLearningRate(Double_t rate)
Definition: TSynapse.h:64
void SetDEDw(Double_t DEDw)
Definition: TSynapse.h:87
Synapse class used by TMVA artificial neural network methods.
Definition: TSynapse.h:44
void SetPostNeuron(TNeuron *post)
Definition: TSynapse.h:70
Double_t GetDelta()
Definition: TSynapse.h:89
int Int_t
Definition: RtypesCore.h:41
TNeuron * fPostNeuron
Definition: TSynapse.h:99
#define ClassDef(name, id)
Definition: Rtypes.h:326
Neuron class used by TMVA artificial neural network methods.
Definition: TNeuron.h:49
Double_t fWeight
Definition: TSynapse.h:93
Double_t GetDEDw()
Definition: TSynapse.h:88
void SetLearningRate(Double_t rate)
Definition: TSynapse.h:58
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 GetWeight()
Definition: TSynapse.h:55
This class describes an elementary neuron, which is the basic element for a Neural Network...
Definition: TNeuron.h:25
double Double_t
Definition: RtypesCore.h:55
void InitDelta()
Definition: TSynapse.h:85
Double_t GetLearningRate()
Definition: TSynapse.h:61
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
void SetPreNeuron(TNeuron *pre)
Definition: TSynapse.h:67
Mother of all ROOT objects.
Definition: TObject.h:37
create variable transformations
virtual ~TSynapse()
destructor
Definition: TSynapse.cxx:62
void CalculateDelta()
calculate/adjust the error field for this synapse
Definition: TSynapse.cxx:109
Double_t fDEDw
Definition: TSynapse.h:96
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
Double_t fDelta
Definition: TSynapse.h:95
MsgLogger & Log() const
Definition: TSynapse.cxx:117