Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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
61  Double_t GetLearningRate() { return fLearnRate; }
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
73  Double_t GetWeightedValue();
74 
75  // get the weighted error field of the post-neuron
76  Double_t GetWeightedDelta();
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