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 * *
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 * (see tmva/doc/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
41
42////////////////////////////////////////////////////////////////////////////////
43/// constructor
44
46 : fWeight( 0 ),
47 fLearnRate( 0 ),
48 fDelta( 0 ),
49 fDEDw( 0 ),
50 fCount( 0 ),
51 fPreNeuron( NULL ),
52 fPostNeuron( NULL )
53{
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// destructor
59
63
64////////////////////////////////////////////////////////////////////////////////
65/// set synapse weight
66
68{
69 fWeight = weight;
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// get output of pre-neuron weighted by synapse weight
74
76{
77 if (fPreNeuron == NULL)
78 Log() << kFATAL << "<GetWeightedValue> synapse not connected to neuron" << Endl;
79
80 return (fWeight * fPreNeuron->GetActivationValue());
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// get error field of post-neuron weighted by synapse weight
85
87{
88 if (fPostNeuron == NULL)
89 Log() << kFATAL << "<GetWeightedDelta> synapse not connected to neuron" << Endl;
90
91 return fWeight * fPostNeuron->GetDelta();
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// adjust the weight based on the error field all ready calculated by CalculateDelta
96
98{
99 Double_t wDelta = fDelta / fCount;
100 fWeight += -fLearnRate * wDelta;
101 InitDelta();
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// calculate/adjust the error field for this synapse
106
108{
109 fDelta += fPostNeuron->GetDelta() * fPreNeuron->GetActivationValue();
110 fCount++;
111}
112
113////////////////////////////////////////////////////////////////////////////////
114
116{
117 TTHREAD_TLS_DECL_ARG(MsgLogger,logger,"TSynapse"); //! message logger, static to save resources
118 return logger;
119}
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ostringstream derivative to redirect and format output
Definition MsgLogger.h:57
void SetWeight(Double_t weight)
set synapse weight
Definition TSynapse.cxx:67
Double_t fWeight
weight of the synapse
Definition TSynapse.h:91
Double_t GetWeightedValue()
get output of pre-neuron weighted by synapse weight
Definition TSynapse.cxx:75
Double_t GetWeightedDelta()
get error field of post-neuron weighted by synapse weight
Definition TSynapse.cxx:86
virtual ~TSynapse()
destructor
Definition TSynapse.cxx:60
TSynapse()
constructor
Definition TSynapse.cxx:45
void AdjustWeight()
adjust the weight based on the error field all ready calculated by CalculateDelta
Definition TSynapse.cxx:97
MsgLogger & Log() const
Definition TSynapse.cxx:115
void CalculateDelta()
calculate/adjust the error field for this synapse
Definition TSynapse.cxx:107
MsgLogger & Endl(MsgLogger &ml)
Definition MsgLogger.h:148
static const Int_t fgUNINITIALIZED
Definition TSynapse.cxx:39