Logo ROOT  
Reference Guide
TSynapse.cxx
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 : TSynapse *
8 * Web : http://tmva.sourceforge.net *
9 * *
10 * Description: *
11 * Implementation (see header for description) *
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/*! \class TMVA::TSynapse
25\ingroup TMVA
26Synapse class used by TMVA artificial neural network methods
27*/
28
29#include "TMVA/TSynapse.h"
30
31#include "TMVA/TNeuron.h"
32
33#include "TMVA/MsgLogger.h"
34
35#include "TMVA/Types.h"
36
37#include "ThreadLocalStorage.h"
38#include "TObject.h"
39
40static const Int_t fgUNINITIALIZED = -1;
41
43
44////////////////////////////////////////////////////////////////////////////////
45/// constructor
46
48 : fWeight( 0 ),
49 fLearnRate( 0 ),
50 fDelta( 0 ),
51 fDEDw( 0 ),
52 fCount( 0 ),
53 fPreNeuron( NULL ),
54 fPostNeuron( NULL )
55{
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// destructor
61
63{
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// set synapse weight
68
70{
71 fWeight = weight;
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// get output of pre-neuron weighted by synapse weight
76
78{
79 if (fPreNeuron == NULL)
80 Log() << kFATAL << "<GetWeightedValue> synapse not connected to neuron" << Endl;
81
82 return (fWeight * fPreNeuron->GetActivationValue());
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// get error field of post-neuron weighted by synapse weight
87
89{
90 if (fPostNeuron == NULL)
91 Log() << kFATAL << "<GetWeightedDelta> synapse not connected to neuron" << Endl;
92
93 return fWeight * fPostNeuron->GetDelta();
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// adjust the weight based on the error field all ready calculated by CalculateDelta
98
100{
101 Double_t wDelta = fDelta / fCount;
102 fWeight += -fLearnRate * wDelta;
103 InitDelta();
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// calculate/adjust the error field for this synapse
108
110{
111 fDelta += fPostNeuron->GetDelta() * fPreNeuron->GetActivationValue();
112 fCount++;
113}
114
115////////////////////////////////////////////////////////////////////////////////
116
118{
119 TTHREAD_TLS_DECL_ARG(MsgLogger,logger,"TSynapse"); //! message logger, static to save resources
120 return logger;
121}
int Int_t
Definition: RtypesCore.h:43
double Double_t
Definition: RtypesCore.h:57
#define ClassImp(name)
Definition: Rtypes.h:361
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
Synapse class used by TMVA artificial neural network methods.
Definition: TSynapse.h:44
void SetWeight(Double_t weight)
set synapse weight
Definition: TSynapse.cxx:69
Double_t fWeight
Definition: TSynapse.h:93
Double_t GetWeightedValue()
get output of pre-neuron weighted by synapse weight
Definition: TSynapse.cxx:77
Double_t GetWeightedDelta()
get error field of post-neuron weighted by synapse weight
Definition: TSynapse.cxx:88
virtual ~TSynapse()
destructor
Definition: TSynapse.cxx:62
TSynapse()
constructor
Definition: TSynapse.cxx:47
void AdjustWeight()
adjust the weight based on the error field all ready calculated by CalculateDelta
Definition: TSynapse.cxx:99
MsgLogger & Log() const
Definition: TSynapse.cxx:117
void CalculateDelta()
calculate/adjust the error field for this synapse
Definition: TSynapse.cxx:109
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:158
Double_t Log(Double_t x)
Definition: TMath.h:750
static const Int_t fgUNINITIALIZED
Definition: TSynapse.cxx:40