Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSynapse.cxx
Go to the documentation of this file.
1// @(#)root/mlp:$Id$
2// Author: Christophe.Delaere@cern.ch 21/08/2002
3
4/*************************************************************************
5 * Copyright (C) 1995-2003, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TSynapse
13
14This is a simple weighted bidirectional connection between
15two neurons.
16A network is built connecting two neurons by a synapse.
17In addition to the value, the synapse can return the DeDw
18
19*/
20
21#include "TSynapse.h"
22#include "TNeuron.h"
23
25
26////////////////////////////////////////////////////////////////////////////////
27/// Default constructor
28
30{
31 fpre = 0;
32 fpost = 0;
33 fweight = 1;
34 fDEDw = 0;
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor that connects two neurons
39
41{
42 fpre = pre;
43 fpost = post;
44 fweight = w;
45 fDEDw = 0;
46 pre->AddPost(this);
47 post->AddPre(this);
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Sets the pre-neuron
52
54{
55 if (fpre) {
56 Error("SetPre","this synapse is already assigned to a pre-neuron.");
57 return;
58 }
59 fpre = pre;
60 pre->AddPost(this);
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Sets the post-neuron
65
67{
68 if (fpost) {
69 Error("SetPost","this synapse is already assigned to a post-neuron.");
70 return;
71 }
72 fpost = post;
73 post->AddPre(this);
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// Returns the value: weighted input
78
80{
81 if (fpre)
82 return (fweight * fpre->GetValue());
83 return 0;
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Computes the derivative of the error wrt the synapse weight.
88
90{
91 if (!(fpre && fpost))
92 return 0;
93 return (fpre->GetValue() * fpost->GetDeDw());
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Sets the weight of the synapse.
98/// This weight is the multiplying factor applied on the
99/// output of a neuron in the linear combination given as input
100/// of another neuron.
101
103{
104 fweight = w;
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Sets the derivative of the total error wrt the synapse weight
109
111{
112 fDEDw = in;
113}
114
115
double Double_t
Definition RtypesCore.h:59
#define ClassImp(name)
Definition Rtypes.h:364
This class describes an elementary neuron, which is the basic element for a Neural Network.
Definition TNeuron.h:25
Double_t GetValue() const
Computes the output using the appropriate function and all the weighted inputs, or uses the branch as...
Definition TNeuron.cxx:944
Double_t GetDeDw() const
Computes the derivative of the error wrt the neuron weight.
Definition TNeuron.cxx:1080
void AddPost(TSynapse *)
Adds a synapse to the neuron as an output This method is used by the TSynapse while connecting two ne...
Definition TNeuron.cxx:842
void AddPre(TSynapse *)
Adds a synapse to the neuron as an input This method is used by the TSynapse while connecting two neu...
Definition TNeuron.cxx:830
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:963
This is a simple weighted bidirectional connection between two neurons.
Definition TSynapse.h:20
TNeuron * fpre
the neuron before the synapse
Definition TSynapse.h:37
void SetPre(TNeuron *pre)
Sets the pre-neuron.
Definition TSynapse.cxx:53
Double_t GetDeDw() const
Computes the derivative of the error wrt the synapse weight.
Definition TSynapse.cxx:89
TNeuron * fpost
the neuron after the synapse
Definition TSynapse.h:38
void SetPost(TNeuron *post)
Sets the post-neuron.
Definition TSynapse.cxx:66
Double_t fDEDw
! the derivative of the total error wrt the synapse weight
Definition TSynapse.h:40
Double_t fweight
the weight of the synapse
Definition TSynapse.h:39
void SetWeight(Double_t w)
Sets the weight of the synapse.
Definition TSynapse.cxx:102
Double_t GetValue() const
Returns the value: weighted input.
Definition TSynapse.cxx:79
void SetDEDw(Double_t in)
Sets the derivative of the total error wrt the synapse weight.
Definition TSynapse.cxx:110
TSynapse()
Default constructor.
Definition TSynapse.cxx:29