Logo ROOT  
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 "TObject.h"
36 
37 namespace TMVA {
38 
39  class TNeuron;
40  class MsgLogger;
41 
42  class TSynapse : public TObject {
43 
44  public:
45 
46  TSynapse();
47  virtual ~TSynapse();
48 
49  // set the weight of the synapse
50  void SetWeight(Double_t weight);
51 
52  // get the weight of the synapse
53  Double_t GetWeight() { return fWeight; }
54 
55  // set the learning rate
56  void SetLearningRate(Double_t rate) { fLearnRate = rate; }
57 
58  // get the learning rate
59  Double_t GetLearningRate() { return fLearnRate; }
60 
61  // decay the learning rate
62  void DecayLearningRate(Double_t rate){ fLearnRate *= (1-rate); }
63 
64  // set the pre-neuron
65  void SetPreNeuron(TNeuron* pre) { fPreNeuron = pre; }
66 
67  // set the post-neuron
68  void SetPostNeuron(TNeuron* post) { fPostNeuron = post; }
69 
70  // get the weighted output of the pre-neuron
72 
73  // get the weighted error field of the post-neuron
75 
76  // force the synapse to adjust its weight according to its error field
77  void AdjustWeight();
78 
79  // calculate the error field of the synapse
81 
82  // initialize the error field of the synapse to 0
83  void InitDelta() { fDelta = 0.0; fCount = 0; }
84 
85  void SetDEDw(Double_t DEDw) { fDEDw = DEDw; }
86  Double_t GetDEDw() { return fDEDw; }
87  Double_t GetDelta() { return fDelta; }
88 
89  private:
90 
91  Double_t fWeight; // weight of the synapse
92  Double_t fLearnRate; // learning rate parameter
93  Double_t fDelta; // local error field
94  Double_t fDEDw; // sum of deltas
95  Int_t fCount; // number of updates contributing to error field
96  TNeuron* fPreNeuron; // pointer to pre-neuron
97  TNeuron* fPostNeuron; // pointer to post-neuron
98 
99  MsgLogger& Log() const;
100 
101  ClassDef(TSynapse,0); // Synapse class used by MethodANNBase and derivatives
102  };
103 
104 } // namespace TMVA
105 
106 #endif
TMVA::TSynapse::fWeight
Double_t fWeight
Definition: TSynapse.h:109
TMVA::TSynapse::GetWeightedDelta
Double_t GetWeightedDelta()
get error field of post-neuron weighted by synapse weight
Definition: TSynapse.cxx:87
TMVA::TSynapse::SetWeight
void SetWeight(Double_t weight)
set synapse weight
Definition: TSynapse.cxx:68
TMVA::TSynapse::GetWeight
Double_t GetWeight()
Definition: TSynapse.h:71
Int_t
int Int_t
Definition: RtypesCore.h:45
TMVA::TSynapse::SetPreNeuron
void SetPreNeuron(TNeuron *pre)
Definition: TSynapse.h:83
TMVA::TSynapse::InitDelta
void InitDelta()
Definition: TSynapse.h:101
TMVA::TSynapse::~TSynapse
virtual ~TSynapse()
destructor
Definition: TSynapse.cxx:61
TMVA::TSynapse::CalculateDelta
void CalculateDelta()
calculate/adjust the error field for this synapse
Definition: TSynapse.cxx:108
TMVA::TSynapse::GetLearningRate
Double_t GetLearningRate()
Definition: TSynapse.h:77
TMVA::TSynapse::TSynapse
TSynapse()
constructor
Definition: TSynapse.cxx:46
TMVA::TSynapse::fDEDw
Double_t fDEDw
Definition: TSynapse.h:112
TMVA::TSynapse::fDelta
Double_t fDelta
Definition: TSynapse.h:111
TMVA::TNeuron
Definition: TNeuron.h:67
TMVA::TSynapse::fLearnRate
Double_t fLearnRate
Definition: TSynapse.h:110
TMVA::TSynapse::fPreNeuron
TNeuron * fPreNeuron
Definition: TSynapse.h:114
TMVA::TSynapse::GetWeightedValue
Double_t GetWeightedValue()
get output of pre-neuron weighted by synapse weight
Definition: TSynapse.cxx:76
TMVA::TSynapse
Definition: TSynapse.h:60
TMVA::TSynapse::fCount
Int_t fCount
Definition: TSynapse.h:113
TMVA::TSynapse::Log
MsgLogger & Log() const
Definition: TSynapse.cxx:116
TMVA::TSynapse::DecayLearningRate
void DecayLearningRate(Double_t rate)
Definition: TSynapse.h:80
TMVA::TSynapse::SetDEDw
void SetDEDw(Double_t DEDw)
Definition: TSynapse.h:103
TMVA::TSynapse::SetPostNeuron
void SetPostNeuron(TNeuron *post)
Definition: TSynapse.h:86
TMVA::TSynapse::GetDelta
Double_t GetDelta()
Definition: TSynapse.h:105
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TMVA::TSynapse::fPostNeuron
TNeuron * fPostNeuron
Definition: TSynapse.h:115
TMVA::TSynapse::SetLearningRate
void SetLearningRate(Double_t rate)
Definition: TSynapse.h:74
TMVA::TSynapse::GetDEDw
Double_t GetDEDw()
Definition: TSynapse.h:104
TSynapse
Definition: TSynapse.h:20
TMVA
create variable transformations
Definition: GeneticMinimizer.h:22
TMVA::TSynapse::AdjustWeight
void AdjustWeight()
adjust the weight based on the error field all ready calculated by CalculateDelta
Definition: TSynapse.cxx:98
TNeuron
Definition: TNeuron.h:25