Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
39static const Int_t fgUNINITIALIZED = -1;
40
42
43////////////////////////////////////////////////////////////////////////////////
44/// constructor
45
47 : fWeight( 0 ),
48 fLearnRate( 0 ),
49 fDelta( 0 ),
50 fDEDw( 0 ),
51 fCount( 0 ),
52 fPreNeuron( NULL ),
53 fPostNeuron( NULL )
54{
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// destructor
60
62{
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// set synapse weight
67
69{
70 fWeight = weight;
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// get output of pre-neuron weighted by synapse weight
75
77{
78 if (fPreNeuron == NULL)
79 Log() << kFATAL << "<GetWeightedValue> synapse not connected to neuron" << Endl;
80
81 return (fWeight * fPreNeuron->GetActivationValue());
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// get error field of post-neuron weighted by synapse weight
86
88{
89 if (fPostNeuron == NULL)
90 Log() << kFATAL << "<GetWeightedDelta> synapse not connected to neuron" << Endl;
91
92 return fWeight * fPostNeuron->GetDelta();
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// adjust the weight based on the error field all ready calculated by CalculateDelta
97
99{
100 Double_t wDelta = fDelta / fCount;
101 fWeight += -fLearnRate * wDelta;
102 InitDelta();
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// calculate/adjust the error field for this synapse
107
109{
110 fDelta += fPostNeuron->GetDelta() * fPreNeuron->GetActivationValue();
111 fCount++;
112}
113
114////////////////////////////////////////////////////////////////////////////////
115
117{
118 TTHREAD_TLS_DECL_ARG(MsgLogger,logger,"TSynapse"); //! message logger, static to save resources
119 return logger;
120}
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
#define ClassImp(name)
Definition Rtypes.h:364
ostringstream derivative to redirect and format output
Definition MsgLogger.h:57
Synapse class used by TMVA artificial neural network methods.
Definition TSynapse.h:42
void SetWeight(Double_t weight)
set synapse weight
Definition TSynapse.cxx:68
Double_t fWeight
Definition TSynapse.h:91
Double_t GetWeightedValue()
get output of pre-neuron weighted by synapse weight
Definition TSynapse.cxx:76
Double_t GetWeightedDelta()
get error field of post-neuron weighted by synapse weight
Definition TSynapse.cxx:87
virtual ~TSynapse()
destructor
Definition TSynapse.cxx:61
TSynapse()
constructor
Definition TSynapse.cxx:46
void AdjustWeight()
adjust the weight based on the error field all ready calculated by CalculateDelta
Definition TSynapse.cxx:98
MsgLogger & Log() const
Definition TSynapse.cxx:116
void CalculateDelta()
calculate/adjust the error field for this synapse
Definition TSynapse.cxx:108
MsgLogger & Endl(MsgLogger &ml)
Definition MsgLogger.h:148
static const Int_t fgUNINITIALIZED
Definition TSynapse.cxx:39