ROOT logo
// @(#)root/tmva $Id: TSynapse.h 39395 2011-05-26 10:05:54Z moneta $
// Author: Matt Jachowski 

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : TMVA::TSynapse                                                        *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Synapse class for use in derivatives of MethodANNBase                     *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Matt Jachowski  <jachowski@stanford.edu> - Stanford University, USA       *
 *                                                                                *
 * Copyright (c) 2005:                                                            *
 *      CERN, Switzerland                                                         *
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/ 

#ifndef ROOT_TMVA_TSynapse
#define ROOT_TMVA_TSynapse

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TSynapse                                                             //
//                                                                      //
// Synapse used by derivatives of MethodANNBase                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TFormula
#include "TFormula.h"
#endif


namespace TMVA {

   class TNeuron;
   class MsgLogger;

   class TSynapse : public TObject {

   public:
    
      TSynapse();
      virtual ~TSynapse();
     
      // set the weight of the synapse
      void SetWeight(Double_t weight);

      // get the weight of the synapse
      Double_t GetWeight()                 { return fWeight;         }

      // set the learning rate
      void SetLearningRate(Double_t rate)  { fLearnRate = rate;      }

      // get the learning rate
      Double_t GetLearningRate()           { return fLearnRate;      }

      // decay the learning rate
      void DecayLearningRate(Double_t rate){ fLearnRate *= (1-rate); }

      // set the pre-neuron
      void SetPreNeuron(TNeuron* pre)      { fPreNeuron = pre;       }

      // set hte post-neuron
      void SetPostNeuron(TNeuron* post)    { fPostNeuron = post;     }

      // get the weighted output of the pre-neuron
      Double_t GetWeightedValue();

      // get the weighted error field of the post-neuron
      Double_t GetWeightedDelta();

      // force the synapse to adjust its weight according to its error field
      void AdjustWeight();

      // calulcate the error field of the synapse
      void CalculateDelta();

      // initialize the error field of the synpase to 0
      void InitDelta()           { fDelta = 0.0; fCount = 0; }

      void SetDEDw(Double_t DEDw)              { fDEDw = DEDw;           }
      Double_t GetDEDw()                       { return fDEDw;           }
      Double_t GetDelta()                      { return fDelta;          }

   private:
  
      Double_t fWeight;            // weight of the synapse
      Double_t fLearnRate;         // learning rate parameter
      Double_t fDelta;             // local error field
      Double_t fDEDw;              // sum of deltas
      Int_t    fCount;             // number of updates contributing to error field
      TNeuron* fPreNeuron;         // pointer to pre-neuron
      TNeuron* fPostNeuron;        // pointer to post-neuron

      static MsgLogger* fgLogger;                     //! message logger, static to save resources
      MsgLogger& Log() const { return *fgLogger; }                       

      ClassDef(TSynapse,0) // Synapse class used by MethodANNBase and derivatives
   };

} // namespace TMVA

#endif
 TSynapse.h:1
 TSynapse.h:2
 TSynapse.h:3
 TSynapse.h:4
 TSynapse.h:5
 TSynapse.h:6
 TSynapse.h:7
 TSynapse.h:8
 TSynapse.h:9
 TSynapse.h:10
 TSynapse.h:11
 TSynapse.h:12
 TSynapse.h:13
 TSynapse.h:14
 TSynapse.h:15
 TSynapse.h:16
 TSynapse.h:17
 TSynapse.h:18
 TSynapse.h:19
 TSynapse.h:20
 TSynapse.h:21
 TSynapse.h:22
 TSynapse.h:23
 TSynapse.h:24
 TSynapse.h:25
 TSynapse.h:26
 TSynapse.h:27
 TSynapse.h:28
 TSynapse.h:29
 TSynapse.h:30
 TSynapse.h:31
 TSynapse.h:32
 TSynapse.h:33
 TSynapse.h:34
 TSynapse.h:35
 TSynapse.h:36
 TSynapse.h:37
 TSynapse.h:38
 TSynapse.h:39
 TSynapse.h:40
 TSynapse.h:41
 TSynapse.h:42
 TSynapse.h:43
 TSynapse.h:44
 TSynapse.h:45
 TSynapse.h:46
 TSynapse.h:47
 TSynapse.h:48
 TSynapse.h:49
 TSynapse.h:50
 TSynapse.h:51
 TSynapse.h:52
 TSynapse.h:53
 TSynapse.h:54
 TSynapse.h:55
 TSynapse.h:56
 TSynapse.h:57
 TSynapse.h:58
 TSynapse.h:59
 TSynapse.h:60
 TSynapse.h:61
 TSynapse.h:62
 TSynapse.h:63
 TSynapse.h:64
 TSynapse.h:65
 TSynapse.h:66
 TSynapse.h:67
 TSynapse.h:68
 TSynapse.h:69
 TSynapse.h:70
 TSynapse.h:71
 TSynapse.h:72
 TSynapse.h:73
 TSynapse.h:74
 TSynapse.h:75
 TSynapse.h:76
 TSynapse.h:77
 TSynapse.h:78
 TSynapse.h:79
 TSynapse.h:80
 TSynapse.h:81
 TSynapse.h:82
 TSynapse.h:83
 TSynapse.h:84
 TSynapse.h:85
 TSynapse.h:86
 TSynapse.h:87
 TSynapse.h:88
 TSynapse.h:89
 TSynapse.h:90
 TSynapse.h:91
 TSynapse.h:92
 TSynapse.h:93
 TSynapse.h:94
 TSynapse.h:95
 TSynapse.h:96
 TSynapse.h:97
 TSynapse.h:98
 TSynapse.h:99
 TSynapse.h:100
 TSynapse.h:101
 TSynapse.h:102
 TSynapse.h:103
 TSynapse.h:104
 TSynapse.h:105
 TSynapse.h:106
 TSynapse.h:107
 TSynapse.h:108
 TSynapse.h:109
 TSynapse.h:110
 TSynapse.h:111
 TSynapse.h:112
 TSynapse.h:113