ROOT logo
// @(#)root/tmva $Id: TSynapse.cxx 29210 2009-06-25 10:44:35Z brun $
// Author: Matt Jachowski 

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : TSynapse                                                              *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Implementation (see header for description)                               *
 *                                                                                *
 * 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)                                          *
 **********************************************************************************/
   
//_______________________________________________________________________
//                                                                      
// Synapse class used by TMVA artificial neural network methods      
//_______________________________________________________________________

#include "TMVA/TSynapse.h"

#ifndef ROOT_TMVA_TNeuron
#include "TMVA/TNeuron.h"
#endif

#ifndef ROOT_TMVA_MsgLogger
#include "TMVA/MsgLogger.h"
#endif

static const Int_t fgUNINITIALIZED = -1;

ClassImp(TMVA::TSynapse);

//______________________________________________________________________________
TMVA::TSynapse::TSynapse()
  : fWeight( 0 ),
    fLearnRate( 0 ),
    fDelta( 0 ),
    fDEDw( 0 ),
    fCount( 0 ),
    fPreNeuron( NULL ),
    fPostNeuron( NULL ),
    fLogger( new MsgLogger("TSynapse") )
{
   // constructor
   fWeight     = fgUNINITIALIZED;
}


//______________________________________________________________________________
TMVA::TSynapse::~TSynapse()
{
   // destructor
   delete fLogger;
}

//______________________________________________________________________________
void TMVA::TSynapse::SetWeight(Double_t weight)
{
   // set synapse weight
   fWeight = weight;
}

//______________________________________________________________________________
Double_t TMVA::TSynapse::GetWeightedValue()
{
   // get output of pre-neuron weighted by synapse weight
   if (fPreNeuron == NULL) 
      Log() << kFATAL << "<GetWeightedValue> synapse not connected to neuron" << Endl;

   return (fWeight * fPreNeuron->GetActivationValue());
}

//______________________________________________________________________________
Double_t TMVA::TSynapse::GetWeightedDelta()
{
   // get error field of post-neuron weighted by synapse weight

   if (fPostNeuron == NULL) 
      Log() << kFATAL << "<GetWeightedDelta> synapse not connected to neuron" << Endl;

   return fWeight * fPostNeuron->GetDelta();
}

//______________________________________________________________________________
void TMVA::TSynapse::AdjustWeight()
{
   // adjust the weight based on the error field all ready calculated by CalculateDelta
   Double_t wDelta = fDelta / fCount;
   fWeight += -fLearnRate * wDelta;
   InitDelta();
}

//______________________________________________________________________________
void TMVA::TSynapse::CalculateDelta()
{
   // calculate/adjust the error field for this synapse
   fDelta += fPostNeuron->GetDelta() * fPreNeuron->GetActivationValue();
   fCount++;
}
 TSynapse.cxx:1
 TSynapse.cxx:2
 TSynapse.cxx:3
 TSynapse.cxx:4
 TSynapse.cxx:5
 TSynapse.cxx:6
 TSynapse.cxx:7
 TSynapse.cxx:8
 TSynapse.cxx:9
 TSynapse.cxx:10
 TSynapse.cxx:11
 TSynapse.cxx:12
 TSynapse.cxx:13
 TSynapse.cxx:14
 TSynapse.cxx:15
 TSynapse.cxx:16
 TSynapse.cxx:17
 TSynapse.cxx:18
 TSynapse.cxx:19
 TSynapse.cxx:20
 TSynapse.cxx:21
 TSynapse.cxx:22
 TSynapse.cxx:23
 TSynapse.cxx:24
 TSynapse.cxx:25
 TSynapse.cxx:26
 TSynapse.cxx:27
 TSynapse.cxx:28
 TSynapse.cxx:29
 TSynapse.cxx:30
 TSynapse.cxx:31
 TSynapse.cxx:32
 TSynapse.cxx:33
 TSynapse.cxx:34
 TSynapse.cxx:35
 TSynapse.cxx:36
 TSynapse.cxx:37
 TSynapse.cxx:38
 TSynapse.cxx:39
 TSynapse.cxx:40
 TSynapse.cxx:41
 TSynapse.cxx:42
 TSynapse.cxx:43
 TSynapse.cxx:44
 TSynapse.cxx:45
 TSynapse.cxx:46
 TSynapse.cxx:47
 TSynapse.cxx:48
 TSynapse.cxx:49
 TSynapse.cxx:50
 TSynapse.cxx:51
 TSynapse.cxx:52
 TSynapse.cxx:53
 TSynapse.cxx:54
 TSynapse.cxx:55
 TSynapse.cxx:56
 TSynapse.cxx:57
 TSynapse.cxx:58
 TSynapse.cxx:59
 TSynapse.cxx:60
 TSynapse.cxx:61
 TSynapse.cxx:62
 TSynapse.cxx:63
 TSynapse.cxx:64
 TSynapse.cxx:65
 TSynapse.cxx:66
 TSynapse.cxx:67
 TSynapse.cxx:68
 TSynapse.cxx:69
 TSynapse.cxx:70
 TSynapse.cxx:71
 TSynapse.cxx:72
 TSynapse.cxx:73
 TSynapse.cxx:74
 TSynapse.cxx:75
 TSynapse.cxx:76
 TSynapse.cxx:77
 TSynapse.cxx:78
 TSynapse.cxx:79
 TSynapse.cxx:80
 TSynapse.cxx:81
 TSynapse.cxx:82
 TSynapse.cxx:83
 TSynapse.cxx:84
 TSynapse.cxx:85
 TSynapse.cxx:86
 TSynapse.cxx:87
 TSynapse.cxx:88
 TSynapse.cxx:89
 TSynapse.cxx:90
 TSynapse.cxx:91
 TSynapse.cxx:92
 TSynapse.cxx:93
 TSynapse.cxx:94
 TSynapse.cxx:95
 TSynapse.cxx:96
 TSynapse.cxx:97
 TSynapse.cxx:98
 TSynapse.cxx:99
 TSynapse.cxx:100
 TSynapse.cxx:101
 TSynapse.cxx:102
 TSynapse.cxx:103
 TSynapse.cxx:104
 TSynapse.cxx:105
 TSynapse.cxx:106
 TSynapse.cxx:107
 TSynapse.cxx:108
 TSynapse.cxx:109